Advertisement
ohhhhhhshdhashdahsd

gk #14 leaked

Jul 3rd, 2015
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 242.91 KB | None | 0 0
  1.  
  2. local RunService = game:service'RunService'
  3. script.Parent=nil;
  4. local Camera = Workspace.CurrentCamera or nil
  5. local Lighting = game.Lighting
  6. local Player = game.Players.LocalPlayer or game.Players.areno2002
  7. local UserInterface = game:service'UserInputService'
  8. local RF = game.ReplicatedStorage:findFirstChild("GKAttachment") or nil
  9. local bannedlist = {"21506048","Dontnukeme"};
  10. local changecamonpossess = false
  11. local Debris = game:service'Debris'
  12. local Mouse = Player:GetMouse() or nil
  13. local Players = game.Players
  14. local chatAdornee = Player.Character.Head
  15. local RbxUtility = LoadLibrary("RbxUtility")
  16. local CMDS = {};
  17. local InsertService = game:service'InsertService'
  18. local math = {
  19. abs = math.abs,
  20. acos = math.acos,
  21. asin = math.asin,
  22. atan = math.atan,
  23. atan2 = math.atan2,
  24. ceil = math.ceil,
  25. cos = math.cos,
  26. cosh = math.cosh,
  27. deg = math.deg,
  28. exp = math.exp,
  29. floor = math.floor,
  30. fmod = math.fmod,
  31. frexp = math.frexp,
  32. huge = math.huge,
  33. ldexp = math.ldexp,
  34. log = math.log,
  35. log10 = math.log10,
  36. max = math.max,
  37. min = math.min,
  38. modf = math.modf,
  39. phi = 1.618033988749895,
  40. pi = math.pi,
  41. pow = math.pow,
  42. rad = math.rad,
  43. random = math.random,
  44. randomseed = math.randomseed,
  45. sin = math.sin,
  46. sinh = math.sinh,
  47. sqrt = math.sqrt,
  48. tan = math.tan,
  49. tanh = math.tanh,
  50. tau = 2 * math.pi
  51. }
  52.  
  53.  
  54. TaskScheduler = {};
  55.  
  56. local currentTime = 0
  57. local pairs = pairs
  58. local rbx_coroutine_create = coroutine.create
  59. local rbx_coroutine_resume = coroutine.resume
  60. local rbx_Wait = Wait
  61. local rbx_ypcall = ypcall
  62. local threads, swapThreads = {}, {}
  63. local function StartCoroutine(func, delay, ...)
  64. if delay > 0 then
  65. rbx_Wait(delay)
  66. end
  67. local success, message = rbx_ypcall(func, ...)
  68. if not success then
  69. print("Error in a TaskScheduler coroutine: "..message)
  70. end
  71. end
  72. function TaskScheduler.GetCurrentTime()
  73. return currentTime
  74. end
  75. function TaskScheduler.MainLoop(stepTime)
  76. currentTime = currentTime + stepTime
  77. threads, swapThreads = swapThreads, threads
  78. local threshold = -0.5 * stepTime
  79. for thread, resumeTime in pairs(swapThreads) do
  80. local remainingTime = currentTime - resumeTime
  81. if remainingTime >= threshold then
  82. swapThreads[thread] = nil
  83. local success, message = coroutine.resume(thread, remainingTime, currentTime)
  84. if not success then
  85. print("Error in a TaskScheduler custom thread: "..message)
  86. end
  87. end
  88. end
  89. threads, swapThreads = swapThreads, threads
  90. for thread, resumeTime in pairs(swapThreads) do
  91. threads[thread], swapThreads[thread] = resumeTime, nil
  92. end
  93. end
  94. -- TODO: add stack trace info to scheduling functions?
  95. function TaskScheduler.Schedule(t, f, ...)
  96. coroutine.resume(coroutine.create(StartCoroutine), f, t, ...)
  97. end
  98. function TaskScheduler.Start(f, ...)
  99. coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
  100. end
  101. function TaskScheduler.ScheduleCustomThread(t, f)
  102. threads[coroutine.create(f)] = currentTime + t
  103. end
  104. function TaskScheduler.Wait(duration)
  105. duration = tonumber(duration) or 0
  106. threads[coroutine.running()] = currentTime + duration
  107. local remainingTime, currentTime = coroutine.yield()
  108. return remainingTime + duration, currentTime
  109. end
  110. local success, player = Players.LocalPlayer
  111. if success and player then
  112. RunService.RenderStepped:connect(function()
  113. TaskScheduler.MainLoop(1 / 60)
  114. end)
  115. else
  116. RunService.Stepped:connect(function()
  117. TaskScheduler.MainLoop(1 / 30)
  118. end)
  119. end
  120.  
  121. ChatBubble = {};
  122.  
  123. local FONT_CUSTOM_A_SRC, FONT_CUSTOM_A, TextAlignment, LoadFixedFont, LoadFont, DrawTextNetwork, DrawMultilineTextNetwork, ConfigureChatBubble,
  124.  
  125. CreateChatBubble, WrapText, chat_bubbles
  126. FONT_CUSTOM_A_SRC = "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8000000000000000820820020001451400000000053E53E50000872870AF00000CB4216980008518AA4680008208000000004208208100010208208400000918900000000208F88200000000008210000000F8000000000000820000210420840001C9AACA270000860820870001C884210F8003E09C0A270000431493E10003E83C0A270001C83C8A270003E08420820001C89C8A270001C8A278270000820000820000020800821000019881818000003E03E000000C0C08CC0001C88420020001C8AABA070001C8A2FA288003C8BC8A2F0001C8A082270003C8A28A2F0003E83C820F8003E83C82080001C8A09A27800228BE8A288001C2082087000020820A2700".."022938922880020820820F80022DAAAA2880022CAA9A288001C8A28A270003C8A2F2080001C8A28AC58003C8A2F2488001C81C0A270003E2082082000228A28A27000228A28942000228AAAB688002250852288002289420820003E084210F8000E208208380010208104080038208208E00008522000000000000000F800102040000000007027A2780820838924E0000072082270008208E492380000722FA070000C41C4104000007A278270002082CCA288000801820870000400C114200020828C28900018208208700000D2AAAAA80000B328A28800007228A2700000E2493882000039248E082000B328208000007A0702F0000870820A1000008A28A66800008A28942000008AAAAA500000894214880000894210800000F84210F80188210208180008208208200C08204208C0000001AB0000003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".."03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".."03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
  127. FONT_CUSTOM_A = {}
  128.  
  129. ChatBubble.THEME = {}
  130. ChatBubble.THEME.AQUA = {
  131. Name = "Aqua",
  132. Background = Color3.new(0, 1 / 3, 0.5),
  133. Foreground = Color3.new(2 / 3, 1, 1)
  134. }
  135. ChatBubble.THEME.CLASSIC = {
  136. Name = "Classic",
  137. Background = Color3.new(0, 0, 0),
  138. Foreground = Color3.new(1, 1, 1)
  139. }
  140.  
  141. ChatBubble.THEME.KAYAVEN = {
  142. Name = "Kayaven",
  143. Background = Color3.new(0, 0, 0),
  144. Foreground = Color3.new(0, 1, 0)
  145. }
  146. ChatBubble.THEME.CRIMSON = {
  147. Name = "Crimson",
  148. Background = Color3.new(0, 0, 0),
  149. Foreground = Color3.new(0.9, 0, 0)
  150. }
  151. ChatBubble.THEME.GRAPE = {
  152. Name = "Grape",
  153. Background = Color3.new(0.25, 0, 0.25),
  154. Foreground = Color3.new(1, 2 / 3, 1)
  155. }
  156. ChatBubble.THEME.LIBERATION = {
  157. Name = "Liberation",
  158. Background = Color3.new(1 / 6, 3 / 7, 3 / 7),
  159. Foreground = Color3.new(1, 1, 1)
  160. }
  161. ChatBubble.THEME.PASSION = {
  162. Name = "Passion",
  163. Background = Color3.new(0.5, 0, 0),
  164. Foreground = Color3.new(1, 1, 1)
  165. }
  166. ChatBubble.THEME.PURPLE = {
  167. Name = "Purple",
  168. Background = Color3.new(0.25, 0, 0.25),
  169. Foreground = Color3.new(1, 1, 1)
  170. }
  171. ChatBubble.THEME.RAINBOW = {
  172. Name = "Rainbow",
  173. Background = function(bubble_info)
  174. local billboard, frame = bubble_info[5], bubble_info[6]
  175. TaskScheduler.Start(function()
  176. while billboard:IsDescendantOf(Workspace) do
  177. local red, green, blue = Utility.GetRainbowRGB(tick())
  178. frame.BackgroundColor3 = Color3.new(0.6 * red, 0.6 * green, 0.65 * blue)
  179. RunService.Stepped:wait()
  180. end
  181. end)
  182. end,
  183. Foreground = Color3.new(1, 1, 1)
  184. }
  185. ChatBubble.THEME.TEAL = {
  186. Name = "Teal",
  187. Background = Color3.new(0, 1 / 3, 0.5),
  188. Foreground = Color3.new(1, 1, 1)
  189. }
  190.  
  191. function ChatBubble.GetTheme()
  192. return ChatBubble.theme_info
  193. end
  194. function ChatBubble.SetTheme(theme_info)
  195. if type(theme_info) == "string" then
  196. theme_info = string.lower(theme_info)
  197. for key, info in pairs(ChatBubble.THEME) do
  198. if info.Name:lower() == theme_info:lower() then
  199. ChatBubble.SetTheme(info)
  200. break
  201. end
  202. end
  203. return
  204. end
  205. ChatBubble.theme_info = theme_info
  206. ChatBubble.background_color = theme_info.Background
  207. ChatBubble.font = LoadFont(ChatBubble.FONT_DEFAULT, theme_info.Foreground)
  208. print("Theme has been set to "..theme_info.Name.." in ChatBubble")
  209. end
  210.  
  211. do
  212. local floor = math.floor
  213. local max = math.max
  214. local asc = string.byte
  215. local chr = string.char
  216. local find = string.find
  217. local gmatch = string.gmatch
  218. local sub = string.sub
  219. local insert = table.insert
  220. local type = type
  221. local unpack = unpack
  222.  
  223. local PopIntegerBit
  224.  
  225. TextAlignment = setmetatable({
  226. [0] = 0,
  227. [1] = 1,
  228. [2] = 2,
  229. Left = 0,
  230. Center = 1,
  231. Right = 2
  232. }, {
  233. __call = function(self, ...)
  234. local argc = #{...}
  235. if argc == 0 then
  236. return 0
  237. else
  238. local arg = (...)
  239. local value = rawget(self, arg)
  240. if value then
  241. return value
  242. else
  243. local arg_type = type(arg)
  244. error("Invalid value" .. ((arg_type == "number") and (" " .. arg) or ((arg_type == "string") and (" \"" .. arg .. "\"") or
  245.  
  246. "")) .. " for enum TextAlignment")
  247. end
  248. end
  249. end
  250. })
  251.  
  252. function PopIntegerBit(value, bit)
  253. if value >= bit then
  254. return 1, value - bit
  255. else
  256. return 0, value
  257. end
  258. end
  259. function LoadFixedFont(dest, src, height, width)
  260. local n = #src / 64 - 1
  261. local bit_index = 0
  262. local symbol_bits = width * height
  263. for i = 0, 255 do
  264. local char_data = {}
  265. for j = 1, height do
  266. char_data[j] = {}
  267. end
  268. dest[i] = char_data
  269. end
  270. for i = 1, #src do
  271. local buffer = tonumber(sub(src, i, i), 16)
  272. for j = 1, 4 do
  273. local code = floor(bit_index / symbol_bits)
  274. local row = floor(bit_index / width) % height + 1
  275. local column = bit_index % width + 1
  276. dest[code][row][column], buffer = PopIntegerBit(buffer, 8)
  277. buffer = buffer * 2
  278. bit_index = bit_index + 1
  279. end
  280. end
  281. end
  282. function LoadFont(font_data, color)
  283. local font_obj = {}
  284. for character, char_data in pairs(font_data) do
  285. local code = character
  286. if type(code) ~= "number" then
  287. code = asc(character)
  288. end
  289. local height = #char_data
  290. local width = #char_data[1]
  291. local pixel_h = 1 / height
  292. local pixel_w = 1 / width
  293. local pixel_size = UDim2.new(pixel_w, 0, pixel_h, 0)
  294. local frame = Instance.new("Frame")
  295. frame.BackgroundTransparency = 1
  296. frame.Name = ""
  297. for y = 1, height do
  298. local row = char_data[y]
  299. for x = 1, width do
  300. local opacity = row[x]
  301. if opacity ~= 0 then
  302. local pixel = Instance.new("Frame", frame)
  303. pixel.BackgroundColor3 = color
  304. pixel.BorderSizePixel = 0
  305. pixel.Name = ""
  306. pixel.Position = UDim2.new(x * pixel_w, 0, y * pixel_h, 0) - pixel_size
  307. pixel.Size = pixel_size -- + UDim2.new(0, 0, 0, 1) -- correction
  308. -- ^ never mind that correction, fixed by changing font size to 12x16 instead of 13x17
  309. if opacity then
  310. pixel.BackgroundTransparency = 1 - opacity
  311. end
  312. end
  313. end
  314. end
  315. font_obj[code] = {frame, height, width}
  316. end
  317. return font_obj
  318. end
  319. function DrawTextNetwork(text, font, size, delay_offset)
  320. if #text == 0 then
  321. text = " "
  322. end
  323. local frame = Instance.new("Frame")
  324. frame.BackgroundTransparency = 1
  325. frame.BorderSizePixel = 0
  326. local objects = {}
  327. local length = #text
  328. local height = 0
  329. local width = 0
  330. for i = 1, length do
  331. local character = sub(text, i, i)
  332. local code = asc(character)
  333. local char_data = assert(font[code] or FONT_SYMBOL_MISSING, "FONT ERROR: '" .. character .. "' (" .. code .. ") not found")
  334. local char_proto, char_h, char_w = unpack(char_data)
  335. objects[i] = char_data
  336. height = max(char_h, height)
  337. width = width + char_w
  338. end
  339. local offset = 0
  340. local punctuation_delay = 0
  341. for i = 1, length do
  342. delay(delay_offset + (i + punctuation_delay - 1) / 30, function()
  343. local char_data = objects[i]
  344. local char_proto, char_h, char_w = unpack(char_data)
  345. local char_obj = char_proto:Clone()
  346. char_obj.Position = UDim2.new(offset / width, 0, 0, 0)
  347. char_obj.Size = UDim2.new(char_w / width, 0, 1, 0)
  348. char_obj.Parent = frame
  349. offset = offset + char_w
  350. end)
  351. local character = sub(text, i, i)
  352. if character == "." then
  353. punctionation_delay = punctuation_delay + 3
  354. elseif character == "?" or character == "!" then
  355. punctionation_delay = punctuation_delay + 2
  356. elseif character == ";" or character == "~" then
  357. punctionation_delay = punctuation_delay + 1
  358. end
  359. end
  360. local ratio = (height == 0) and (0) or (width / height)
  361. frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale, size.Y.Offset)
  362. return frame, height, width, (length + punctuation_delay) / 30
  363. end
  364. function DrawMultilineTextNetwork(text, font, size, delay_offset, ...)
  365. local align = TextAlignment(...)
  366. local frame = Instance.new("Frame")
  367. frame.BackgroundTransparency = 1
  368. frame.BorderSizePixel = 0
  369. local height = 0
  370. local width = 0
  371. local objects = {}
  372. for line in gmatch(text .. "\n", "([^\n]*)\n") do
  373. local line_obj, line_h, line_w, line_delay = DrawTextNetwork(line, font, size, delay_offset)
  374. insert(objects, {line_obj, line_h, line_w})
  375. height = height + line_h
  376. width = max(line_w, width)
  377. delay_offset = delay_offset + line_delay
  378. end
  379. local offset = 0
  380. for index, line_data in ipairs(objects) do
  381. local line_obj, line_h, line_w = unpack(line_data)
  382. local align_offset
  383. if align == TextAlignment.Left then
  384. align_offset = 0
  385. elseif align == TextAlignment.Center then
  386. align_offset = 0.5 - line_w / width / 2
  387. elseif align == TextAlignment.Right then
  388. align_offset = 1 - line_w / width
  389. end
  390. line_obj.Position = UDim2.new(align_offset, 0, offset / height, 0)
  391. line_obj.Parent = frame
  392. offset = offset + line_h
  393. end
  394. local line_count = #objects
  395. local ratio = (height == 0) and (0) or (line_count * width / height)
  396. frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale * line_count, size.Y.Offset * line_count)
  397. return frame, height, width
  398. end
  399. end
  400.  
  401. LoadFixedFont(FONT_CUSTOM_A, FONT_CUSTOM_A_SRC, 8, 6)
  402. ChatBubble.FONT_DEFAULT = FONT_CUSTOM_A
  403. ChatBubble.SetTheme("Rainbow")
  404.  
  405. chat_bubbles = {}
  406.  
  407. function CreateChatBubble(bubble_info)
  408. local creation_time, text, backup = bubble_info[1], bubble_info[2], bubble_info[8]
  409. local billboard, frame, label
  410. if backup and false then
  411. billboard = backup:Clone()
  412. frame = billboard.Frame
  413. label = frame.Label
  414. bubble_info[5] = billboard
  415. bubble_info[6] = frame
  416. bubble_info[7] = label
  417. billboard.Parent = Workspace
  418. else
  419. label = DrawMultilineTextNetwork(text, bubble_info[9], UDim2.new(0, 12, 0, 16), creation_time - time(), "Center")
  420. label.Name = "Label"
  421. label.Position = UDim2.new(0, 16, 0, 16)
  422. billboard = Instance.new("BillboardGui", Workspace)
  423. billboard.Adornee = chatAdornee
  424. billboard.AlwaysOnTop = true
  425. billboard.Size = UDim2.new(label.Size.X.Scale, label.Size.X.Offset + 32, label.Size.Y.Scale, label.Size.Y.Offset + 32)
  426. billboard.SizeOffset = Vector2.new(0, 0)
  427. billboard.StudsOffset = Vector3.new(0, 1, 0)
  428. frame = Instance.new("Frame", billboard)
  429. bubble_info[5] = billboard
  430. bubble_info[6] = frame
  431. bubble_info[7] = label
  432. local background_color = bubble_info[10]
  433. if type(background_color) == "function" then
  434. background_color(bubble_info)
  435. else
  436. frame.BackgroundColor3 = background_color
  437. end
  438. frame.BackgroundTransparency = 0.3
  439. frame.BorderSizePixel = 0
  440. frame.ClipsDescendants = true
  441. frame.Name = "Frame"
  442. frame.Size = UDim2.new(1, 0, 0, 0)
  443. label.Parent = frame
  444. -- bubble_info[8] = billboard:Clone()
  445. end
  446. end
  447. local tween_time = 0.3
  448. function ConfigureChatBubble(bubble_info)
  449. local creation_time, destruction_time, billboard, frame = bubble_info[1], bubble_info[3], bubble_info[5], bubble_info[6]
  450. if not billboard or billboard.Parent ~= workspace then
  451. CreateChatBubble(bubble_info)
  452. billboard, frame = bubble_info[5], bubble_info[6]
  453. end
  454. if billboard.Adornee ~= chatAdornee then
  455. billboard.Adornee = chatAdornee
  456. end
  457. local current_time = time()
  458. local elapsed_time = current_time - creation_time
  459. local remaining_time = destruction_time - current_time
  460. if remaining_time < 0 then
  461. bubble_info[4] = false
  462. billboard:Destroy()
  463. return false
  464. elseif remaining_time < tween_time then
  465. local tween_progress = math.sin(remaining_time * math.pi / (tween_time * 2))
  466. frame.Size = UDim2.new(1, 0, tween_progress, 0)
  467. elseif elapsed_time < tween_time then
  468. local tween_progress = math.sin(elapsed_time * math.pi / (tween_time * 2))
  469. frame.Size = UDim2.new(1, 0, tween_progress, 0)
  470. elseif frame.Size ~= UDim2.new(1, 0, 1, 0) then
  471. frame.Size = UDim2.new(1, 0, 1, 0)
  472. end
  473. return true
  474. end
  475. function ChatBubble.MainLoop()
  476. local offset = 0
  477. local removing = {}
  478. for index, bubble_info in ipairs(chat_bubbles) do
  479. if not ConfigureChatBubble(bubble_info) then
  480. removing[#removing + 1] = index - #removing
  481. else
  482. local billboard, frame = bubble_info[5], bubble_info[6]
  483. local billboard_h = billboard.Size.Y.Offset
  484. local bubble_h = frame.Size.Y.Scale * billboard_h
  485. offset = 8 + offset + bubble_h
  486. billboard.SizeOffset = Vector2.new(0, offset / billboard_h - 0.5)
  487. end
  488. end
  489. for index, bubble_index in ipairs(removing) do
  490. table.remove(chat_bubbles, bubble_index)
  491. end
  492. RunService.Stepped:wait()
  493. end
  494. function WrapText(text, character_limit, line_length_limit)
  495. if #text > character_limit then
  496. text = string.sub(text, 1, character_limit - 3) .. "..."
  497. end
  498. local text_length = #text
  499. local line_length = 0
  500. local i = 0
  501. while i <= text_length do
  502. i = i + 1
  503. local character = string.sub(text, i, i)
  504. if character == "\t" then
  505. local tabulation_size = 4 - line_length % 4
  506. line_length = line_length + tabulation_size
  507. if line_length >= line_length_limit then
  508. tabulation_size = line_length - line_length_limit
  509. line_length = 0
  510. text_length = text_length + tabulation_size
  511. text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. "\n" .. string.sub(text, i + 1)
  512. i = i + tabulation_size + 1
  513. else
  514. text_length = text_length + tabulation_size - 1
  515. text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. string.sub(text, i + 1)
  516. i = i + tabulation_size - 1
  517. end
  518. elseif character == "\n" then
  519. line_length = 0
  520. else
  521. line_length = line_length + 1
  522. if line_length >= line_length_limit then
  523. local k = i - line_length + 1
  524. local success = false
  525. for j = i, k, -1 do
  526. if string.match(string.sub(text, j, j), "[ \t]") then
  527. text = string.sub(text, 1, j - 1) .. "\n" .. string.sub(text, j + 1)
  528. text_length = text_length + 1
  529. success = true
  530. break
  531. end
  532. end
  533. if not success then
  534. text = string.sub(text, 1, i) .. "\n" .. string.sub(text, i + 1)
  535. text_length = text_length + 1
  536. end
  537. i = i + 1
  538. line_length = 0
  539. end
  540. end
  541. end
  542. if #text > character_limit then
  543. text = string.sub(text, 1, character_limit - 3) .. "..."
  544. end
  545. return text
  546. end
  547. function ChatBubble.Create(text, theme)
  548. local text = WrapText(text, 200, 30)
  549. local creation_time = time()
  550. local bubble_info = {creation_time, text, creation_time + 6 + #text / 15, true}
  551. local previousTheme
  552. if theme then
  553. previousTheme = ChatBubble.GetTheme()
  554. ChatBubble.SetTheme(theme)
  555. end
  556. bubble_info[9] = ChatBubble.font
  557. bubble_info[10] = ChatBubble.background_color
  558. if previousTheme then
  559. ChatBubble.SetTheme(previousTheme)
  560. end
  561. table.insert(chat_bubbles, 1, bubble_info)
  562. end
  563. TaskScheduler.Start(function()
  564. while true do
  565. ChatBubble.MainLoop()
  566. end
  567. end)
  568.  
  569. PyramidCharacter = {};
  570.  
  571. local stock_triangle = Instance.new("WedgePart")
  572. stock_triangle.Anchored = true
  573. stock_triangle.BottomSurface = "Smooth"
  574. stock_triangle.FormFactor = "Custom"
  575. stock_triangle.Locked = true
  576. stock_triangle.TopSurface = "Smooth"
  577. local stock_triangle_mesh = Instance.new("SpecialMesh", stock_triangle)
  578. stock_triangle_mesh.MeshType = "Wedge"
  579. local triangles = {}
  580. function PyramidCharacter.CreateTriangle(v1, v2, v3, properties, parent, index)
  581. local triangleInfo = triangles[index]
  582. local side1 = (v1 - v2).magnitude
  583. local side2 = (v2 - v3).magnitude
  584. local side3 = (v3 - v1).magnitude
  585. local sqrside1 = side1 * side1
  586. local sqrside2 = side2 * side2
  587. local sqrside3 = side3 * side3
  588. if sqrside3 + sqrside1 == sqrside2 then
  589. v1, v2, v3 = v1, v2, v3
  590. elseif sqrside1 + sqrside2 == sqrside3 then
  591. v1, v2, v3 = v2, v3, v1
  592. elseif sqrside2 + sqrside3 == sqrside1 then
  593. v1, v2, v3 = v3, v1, v2
  594. elseif sqrside1 >= sqrside2 and sqrside1 >= sqrside3 then
  595. v1, v2, v3 = v1, v2, v3
  596. elseif sqrside2 >= sqrside3 and sqrside2 >= sqrside1 then
  597. v1, v2, v3 = v2, v3, v1
  598. else
  599. v1, v2, v3 = v3, v1, v2
  600. end
  601. local model, part1, part2, mesh1, mesh2
  602. if triangleInfo then
  603. model, part1, part2, mesh1, mesh2 = unpack(triangleInfo)
  604. if not (model.Parent == parent and part1.Parent == model and part2.Parent == model and mesh1.Parent == part1 and mesh2.Parent == part2) then
  605. if model.Parent then
  606. model:Destroy()
  607. end
  608. model = nil
  609. end
  610. else
  611. triangleInfo = {}
  612. triangles[index] = triangleInfo
  613. end
  614. if not model then
  615. model = Instance.new("Model")
  616. part1 = stock_triangle:Clone()
  617. part2 = stock_triangle:Clone()
  618. mesh1 = part1.Mesh
  619. mesh2 = part2.Mesh
  620. part1.Parent = model
  621. part2.Parent = model
  622. triangleInfo[1] = model
  623. triangleInfo[2] = part1
  624. triangleInfo[3] = part2
  625. triangleInfo[4] = mesh1
  626. triangleInfo[5] = mesh2
  627. end
  628. for key, value in pairs(properties) do
  629. part1[key] = value
  630. part2[key] = value
  631. end
  632. local cframe = CFrame.new(v1, v2)
  633. local relpos = cframe:pointToObjectSpace(v3)
  634. cframe = cframe * CFrame.fromEulerAnglesXYZ(0, 0, -math.atan2(relpos.x, relpos.y))
  635. local rel1 = cframe:pointToObjectSpace(v1)
  636. local rel2 = cframe:pointToObjectSpace(v2)
  637. local rel3 = cframe:pointToObjectSpace(v3)
  638. local height = rel3.y
  639. local width1 = rel3.z
  640. local width2 = rel2.z - rel3.z
  641. local relcenter1 = Vector3.new(0, height / 2, width1 / 2)
  642. local center1 = cframe:pointToWorldSpace(relcenter1)
  643. local relcenter2 = Vector3.new(0, height / 2, width2 / 2 + width1)
  644. local center2 = cframe:pointToWorldSpace(relcenter2)
  645. height = math.abs(height)
  646. width1 = math.abs(width1)
  647. width2 = math.abs(width2)
  648. if not part1.Anchored then
  649. part1.Anchored = true
  650. end
  651. part1.Size = Vector3.new(0.2, height, width1)
  652. part1.CFrame = cframe * CFrame.fromEulerAnglesXYZ(0, math.pi, 0) - cframe.p + center1
  653. mesh1.Scale = Vector3.new(0, height / part1.Size.y, width1 / part1.Size.z)
  654. if not part2.Anchored then
  655. part2.Anchored = true
  656. end
  657. part2.Size = Vector3.new(0.2, height, width1)
  658. part2.CFrame = cframe - cframe.p + center2
  659. mesh2.Scale = Vector3.new(0, height / part1.Size.y, width2 / part2.Size.z)
  660. model.Parent = parent
  661. return model
  662. end
  663. PyramidCharacter.head_properties = {BrickColor = BrickColor.new(Color3.new(1, 1, 1)), Transparency = 0.5}
  664. PyramidCharacter.head_radius = math.pi
  665. PyramidCharacter.center = CFrame.new(0, 10, 0)
  666. PyramidCharacter.point1 = Vector3.new()
  667. PyramidCharacter.point2 = Vector3.new()
  668. PyramidCharacter.point3 = Vector3.new()
  669. PyramidCharacter.point4 = Vector3.new()
  670. PyramidCharacter.core_mesh_scale = Vector3.new(0.833, 0.833, 0.833)
  671. PyramidCharacter.visible = false
  672. function PyramidCharacter.Teleport(location)
  673. PyramidCharacter.point1 = location
  674. PyramidCharacter.point2 = location
  675. PyramidCharacter.point3 = location
  676. PyramidCharacter.point4 = location
  677. end
  678. local stock_core = Instance.new("Part")
  679. stock_core.Anchored = true
  680. stock_core.BottomSurface = "Smooth"
  681. stock_core.Color = Color3.new(1, 1, 1)
  682. stock_core.FormFactor = "Custom"
  683. stock_core.Locked = true
  684. stock_core.Name = "CubePyramid"
  685. stock_core.Size = Vector3.new(0.5, 0.5, 0.5)
  686. stock_core.TopSurface = "Smooth"
  687. PyramidCharacter.stock_core = stock_core
  688. PyramidCharacter.core = stock_core:Clone()
  689. PyramidCharacter.Archivable = false
  690. PyramidCharacter.core_mesh = Instance.new("BlockMesh", core)
  691. PyramidCharacter.core_lights = {}
  692. PyramidCharacter.coreLightCount = 1
  693. for index = 1, PyramidCharacter.coreLightCount do
  694. PyramidCharacter.core_lights[index] = Instance.new("PointLight", core)
  695. end
  696. PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
  697. PyramidCharacter.camera_position = Vector3.new()
  698. Camera.Changed:connect(function(property)
  699. if PyramidCharacter.visible then
  700. if property == "CoordinateFrame" then
  701. local cframe, focus = Camera.CoordinateFrame, Camera.Focus
  702. local eventTime = time()
  703. local connection
  704. connection = Camera.Changed:connect(function()
  705. connection:disconnect()
  706. if eventTime == time() and Camera.Focus ~= focus then
  707. local camera_distance = PyramidCharacter.camera_distance
  708. Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  709. PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  710. end
  711. end)
  712. coroutine.yield()
  713. if Camera.Focus == focus then
  714. PyramidCharacter.camera_distance = (focus.p - cframe.p).magnitude
  715. else
  716. local camera_distance = PyramidCharacter.camera_distance
  717. Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  718. PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  719. end
  720. if connection.connected then
  721. connection:disconnect()
  722. end
  723. end
  724. end
  725. end)
  726. function PyramidCharacter.Animate()
  727. local total_time = time()
  728. local core = PyramidCharacter.core
  729. local frame = PyramidCharacter.frame
  730. if PyramidCharacter.visible then
  731. local core_mesh = PyramidCharacter.core_mesh
  732. local core_lights = PyramidCharacter.core_lights
  733. if not frame or frame.Parent ~= core then
  734. frame = Instance.new("Model")
  735. frame.Archivable = false
  736. frame.Parent = core
  737. PyramidCharacter.frame = frame
  738. end
  739. if core.Parent ~= Workspace then
  740. core = PyramidCharacter.stock_core:Clone()
  741. PyramidCharacter.core = core
  742. core.Archivable = false
  743. core.Parent = Workspace
  744. chatAdornee = core
  745. end
  746. if core_mesh.Parent ~= core then
  747. core_mesh = Instance.new("BlockMesh", core)
  748. PyramidCharacter.core_mesh = core_mesh
  749. end
  750. for index, core_light in ipairs(core_lights) do
  751. if core_light.Parent ~= core then
  752. core_light = Instance.new("PointLight", core)
  753. core_lights[index] = core_light
  754. end
  755. local vertexColor = Vector3.new(Utility.GetRainbowRGB(total_time)) * 0.25 + Vector3.new(1, 1, 1) * 0.75
  756. core_light.Color = Color3.new(vertexColor.X, vertexColor.Y, vertexColor.Z)
  757. core_light.Brightness = 0.85 + 0.15 * math.random()
  758. if core_light.Range ~= 30 then
  759. core_light.Range = 30
  760. end
  761. if not core_light.Shadows then
  762. core_light.Shadows = true
  763. end
  764. end
  765. if core_mesh.Offset ~= Vector3.new(0, 0, 0) then
  766. core_mesh.Offset = Vector3.new(0, 0, 0)
  767. end
  768. if not core.Anchored then
  769. core.Anchored = true
  770. end
  771. if core.Transparency ~= 0 then
  772. core.Transparency = 0
  773. end
  774. local core_mesh_scale = PyramidCharacter.core_mesh_scale
  775. local transition_speed = (math.sin(total_time * math.tau) + 1) / 16
  776. core_mesh_scale = core_mesh_scale * (1 - transition_speed) + Vector3.new(math.random() * 0.5 + 0.5, math.random() * 0.5 + 0.5, math.random()
  777.  
  778. * 0.5 + 0.5) * transition_speed
  779. core_mesh.Scale = core_mesh_scale * 2
  780. local center = CFrame.new(PyramidCharacter.camera_position) * CFrame.Angles(0, total_time * math.tau, 0)
  781. local cframe1 = CFrame.new(PyramidCharacter.head_radius, 0, 0)
  782. local cframe2 = CFrame.Angles(math.tau / -3, 0, 0)
  783. local cframe3 = CFrame.Angles(0, math.tau / 3, 0)
  784. local cframe4 = center * cframe3
  785. local desired1 = center * CFrame.new(0, PyramidCharacter.head_radius, 0)
  786. local desired2 = center * cframe2 * cframe1
  787. local desired3 = cframe4 * cframe2 * cframe1
  788. local desired4 = cframe4 * cframe3 * cframe2 * cframe1
  789. local point1 = (PyramidCharacter.point1 * 3 + desired1.p) / 4
  790. local point2 = (PyramidCharacter.point2 * 3 + desired2.p) / 4
  791. local point3 = (PyramidCharacter.point3 * 3 + desired3.p) / 4
  792. local point4 = (PyramidCharacter.point4 * 3 + desired4.p) / 4
  793. PyramidCharacter.point1 = point1
  794. PyramidCharacter.point2 = point2
  795. PyramidCharacter.point3 = point3
  796. PyramidCharacter.point4 = point4
  797. local head_properties = PyramidCharacter.head_properties
  798. PyramidCharacter.CreateTriangle(point1, point2, point3, head_properties, frame, 1).Archivable = false
  799. PyramidCharacter.CreateTriangle(point2, point3, point4, head_properties, frame, 2).Archivable = false
  800. PyramidCharacter.CreateTriangle(point3, point4, point1, head_properties, frame, 3).Archivable = false
  801. PyramidCharacter.CreateTriangle(point4, point1, point2, head_properties, frame, 4).Archivable = false
  802. core.CFrame = CFrame.new((point1 + point2 + point3 + point4) / 4) * CFrame.Angles(total_time * math.tau, total_time * math.tau / 2,
  803.  
  804. total_time * math.tau / 3)
  805. PyramidCharacter.center = center
  806. else
  807. if core.Parent then
  808. core:Destroy()
  809. end
  810. if frame and frame.Parent then
  811. frame:Destroy()
  812. end
  813. PyramidCharacter.frame = nil
  814. end
  815. end
  816. function PyramidCharacter.MainLoop()
  817. PyramidCharacter.Animate()
  818. RunService.Stepped:wait()
  819. end
  820. TaskScheduler.Start(function()
  821. while true do
  822. PyramidCharacter.MainLoop()
  823. end
  824. end)
  825.  
  826. RBXInstance = {};
  827.  
  828. RBXInstance.init_metatable = {}
  829. function RBXInstance.init_metatable:__call(data)
  830. local instance = Instance.new(self[1])
  831. for key, value in pairs(data) do
  832. if type(key) == "number" then
  833. value.Parent = instance
  834. else
  835. instance[key] = value
  836. end
  837. end
  838. return instance
  839. end
  840. function RBXInstance.new(className)
  841. return setmetatable({className}, RBXInstance.init_metatable)
  842. end
  843.  
  844. Utility = {};
  845.  
  846. function Utility.CleanLighting()
  847. Lighting.Ambient = Color3.new(0, 0, 0)
  848. Lighting.Brightness = 1
  849. Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
  850. Lighting.ColorShift_Top = Color3.new(0, 0, 0)
  851. Lighting.FogColor = Color3.new(0.75294125080109, 0.75294125080109, 0.75294125080109)
  852. Lighting.FogEnd = 100000
  853. Lighting.FogStart = 0
  854. Lighting.GeographicLatitude = 41.733299255371095
  855. Lighting.GlobalShadows = true
  856. Lighting.OutdoorAmbient = Color3.new(0.5, 0.5, 0.5)
  857. Lighting.Outlines = false
  858. Lighting.ShadowColor = Color3.new(0.70196080207825, 0.70196080207825, 0.72156864404678)
  859. Lighting.TimeOfDay = "14:00:00"
  860. for index, child in ipairs(Lighting:GetChildren()) do
  861. if child:IsA("Sky") then
  862. child:Destroy()
  863. end
  864. end
  865. end
  866.  
  867. function Utility.GetProperty(object, field)
  868. return object[field]
  869. end
  870.  
  871. function Utility.CaseInsensitivePattern(pattern)
  872. return string.gsub(pattern, "(%%?)(.)", Utility.CaseInsensitivePatternReplaceFunc)
  873. end
  874. function Utility.CaseInsensitivePatternReplaceFunc(percent, letter)
  875. if percent ~= "" or not letter:match("%a") then
  876. return percent .. letter
  877. else
  878. return "[" .. string.lower(letter) .. string.upper(letter) .. "]"
  879. end
  880. end
  881. function Utility.FindHumanoidClosestToRay(ray, exlusionList)
  882. local view = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
  883. local inverseView = view:inverse()
  884. local objects = Workspace:GetChildren()
  885. local numObjects = #objects
  886. local minDistance = math.huge
  887. local closestHumanoid, closestTorso, closestTorsoPosition
  888. for index, object in ipairs(objects) do
  889. for index, child in ipairs(object:GetChildren()) do
  890. numObjects = numObjects + 1
  891. objects[numObjects] = child
  892. end
  893. if object.ClassName == "Humanoid" and object.Health > 0 then
  894. local torso = object.Torso
  895. if torso and not (exlusionList and exlusionList[torso]) then
  896. local torsoPosition = torso.Position
  897. local relativePosition = inverseView * torsoPosition
  898. local distanceZ = -relativePosition.Z
  899. if distanceZ > 0 then
  900. local distance = (inverseView * torsoPosition * Vector3.new(1, 1, 0)).magnitude / distanceZ
  901. if distance < 0.25 and distance < minDistance then
  902. closestHumanoid = object
  903. closestTorso = torso
  904. closestTorsoPosition = torsoPosition
  905. minDistance = distance
  906. end
  907. end
  908. end
  909. end
  910. end
  911. return closestHumanoid, closestTorso, closestTorsoPosition, minDistance
  912. end
  913. function Utility.FindLocalHead()
  914. if Player then
  915. local head, position, view
  916. pcall(function()
  917. position = Camera.Focus.p
  918. view = Camera.CoordinateFrame
  919. end)
  920. pcall(function()
  921. for _, child in ipairs(Workspace:GetChildren()) do
  922. if Players:GetPlayerFromCharacter(child) == Player then
  923. for _, child in ipairs(child:GetChildren()) do
  924. if tostring(child) == "Head" and pcall(assert, pcall(Game.IsA, child, "BasePart")) then
  925. head = child
  926. break
  927. end
  928. end
  929. break
  930. end
  931. end
  932. if not head and view then
  933. local min_distance = math.huge
  934. local objects = Workspace:GetChildren()
  935. for _, object in ipairs(objects) do
  936. local success, is_part = pcall(Game.IsA, object, "BasePart")
  937. if success and is_part then
  938. pcall(function()
  939. local distance = (view:pointToObjectSpace(object.Position) * Vector3.new(1, 1, 0)).magnitude
  940. if distance < min_distance and distance < 1 then
  941. min_distance = distance
  942. head = object
  943. elseif tostring(object) == "Head" and tostring(object.Parent):lower():match("^" .. tostring(Player):lower()) then
  944. min_distance = 0
  945. head = object
  946. end
  947. end)
  948. if min_distance < 5e-4 then
  949. break
  950. end
  951. end
  952. pcall(function()
  953. if not object:IsA("Camera") then
  954. for _, child in ipairs(object:GetChildren()) do
  955. objects[#objects + 1] = child
  956. end
  957. end
  958. end)
  959. end
  960. end
  961. end)
  962. return head, position, view
  963. end
  964. end
  965. function Utility.GetBuildingTools()
  966. local backpack = Player:FindFirstChild("Backpack")
  967. if backpack then
  968. local moveTool = Instance.new("HopperBin")
  969. local cloneTool = Instance.new("HopperBin")
  970. local deleteTool = Instance.new("HopperBin")
  971. moveTool.BinType = Enum.BinType.GameTool
  972. cloneTool.BinType = Enum.BinType.Clone
  973. deleteTool.BinType = Enum.BinType.Hammer
  974. moveTool.Parent = backpack
  975. cloneTool.Parent = backpack
  976. deleteTool.Parent = backpack
  977. end
  978. end
  979. function Utility.Rejoin()
  980. Workspace.Parent:service'TeleportService':Teleport(Game.PlaceId)
  981. end
  982.  
  983. function Utility.BlockRobloxFilter(text)
  984. return string.gsub(text, ".", "%1\143")
  985. end
  986.  
  987. function Utility.GetTimestamp()
  988. local unix_time = tick()
  989. local time_secs = math.floor(unix_time % 60)
  990. local time_mins = math.floor(unix_time / 60 % 60)
  991. local time_hours = math.floor(unix_time / 3600 % 24)
  992. return string.format("%02i:%02i:%02i", time_hours, time_mins, time_secs)
  993. end
  994.  
  995. function Utility.GetRainbowRGB(hue)
  996. local section = hue % 1 * 3
  997. local secondary = 0.5 * math.pi * (section % 1)
  998. if section < 1 then
  999. return 1, 1 - math.cos(secondary), 1 - math.sin(secondary)
  1000. elseif section < 2 then
  1001. return 1 - math.sin(secondary), 1, 1 - math.cos(secondary)
  1002. else
  1003. return 1 - math.cos(secondary), 1 - math.sin(secondary), 1
  1004. end
  1005. end
  1006.  
  1007. function Utility.SetProperty(object, field, value)
  1008. object[field] = value
  1009. end
  1010.  
  1011. function Utility.CleanWorkspace()
  1012. for index, child in ipairs(Workspace:GetChildren()) do
  1013. if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child:IsA("Script") or child.ClassName == "Terrain") then
  1014. pcall(child.Destroy, child)
  1015. end
  1016. end
  1017. Workspace.Terrain:Clear()
  1018. local base = Instance.new("Part")
  1019. base.Anchored = true
  1020. base.BrickColor = BrickColor.new("Earth green")
  1021. base.Locked = true
  1022. base.Name = "Base"
  1023. base.Size = Vector3.new(512, 1.2, 512)
  1024. base.Parent = Workspace
  1025. end
  1026.  
  1027. function Utility.CleanWorkspaceAndScripts()
  1028. for index, child in ipairs(Workspace:GetChildren()) do
  1029. if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child.ClassName == "Terrain") then
  1030. pcall(child.Destroy, child)
  1031. end
  1032. end
  1033. Workspace.Terrain:Clear()
  1034. local base = Instance.new("Part")
  1035. base.Anchored = true
  1036. base.BrickColor = BrickColor.new("Earth green")
  1037. base.Locked = true
  1038. base.Name = "Base"
  1039. base.Size = Vector3.new(512, 1.2, 512)
  1040. base.Parent = Workspace
  1041. end
  1042.  
  1043. function Utility.CreateDummy(cframe, name, parent)
  1044. local model = Instance.new("Model")
  1045. model.Archivable = false
  1046. model.Name = name
  1047. local humanoid = Instance.new("Humanoid", model)
  1048. local head = Instance.new("Part", model)
  1049. local face = Instance.new("Decal", head)
  1050. local head_mesh = Instance.new("SpecialMesh", head)
  1051. local torso = Instance.new("Part", model)
  1052. local right_arm = Instance.new("Part", model)
  1053. local left_arm = Instance.new("Part", model)
  1054. local right_leg = Instance.new("Part", model)
  1055. local left_leg = Instance.new("Part", model)
  1056. local neck = Instance.new("Motor", torso)
  1057. local right_shoulder = Instance.new("Motor", torso)
  1058. local left_shoulder = Instance.new("Motor", torso)
  1059. local right_hip = Instance.new("Motor", torso)
  1060. local left_hip = Instance.new("Motor", torso)
  1061. head.BrickColor = BrickColor.Yellow()
  1062. head.CFrame = cframe * CFrame.new(0, 1.5, 0)
  1063. head.FormFactor = "Symmetric"
  1064. head.Locked = true
  1065. head.Name = "Head"
  1066. head.Size = Vector3.new(2, 1, 1)
  1067. head.TopSurface = "Smooth"
  1068. face.Texture = "rbxasset://textures/face.png"
  1069. head_mesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  1070. torso.BrickColor = BrickColor.Blue()
  1071. torso.CFrame = cframe
  1072. torso.FormFactor = "Symmetric"
  1073. torso.LeftSurface = "Weld"
  1074. torso.Locked = true
  1075. torso.RightSurface = "Weld"
  1076. torso.Name = "Torso"
  1077. torso.Size = Vector3.new(2, 2, 1)
  1078. right_arm.BrickColor = BrickColor.Yellow()
  1079. right_arm.CanCollide = false
  1080. right_arm.CFrame = cframe * CFrame.new(1.5, 0, 0)
  1081. right_arm.FormFactor = "Symmetric"
  1082. right_arm.Locked = true
  1083. right_arm.Name = "Right Arm"
  1084. right_arm.Size = Vector3.new(1, 2, 1)
  1085. left_arm.BrickColor = BrickColor.Yellow()
  1086. left_arm.CanCollide = false
  1087. left_arm.CFrame = cframe * CFrame.new(-1.5, 0, 0)
  1088. left_arm.FormFactor = "Symmetric"
  1089. left_arm.Locked = true
  1090. left_arm.Name = "Left Arm"
  1091. left_arm.Size = Vector3.new(1, 2, 1)
  1092. right_leg.BrickColor = BrickColor.new("Br. yellowish green")
  1093. right_leg.BottomSurface = "Smooth"
  1094. right_leg.CanCollide = false
  1095. right_leg.CFrame = cframe * CFrame.new(0.5, -2, 0)
  1096. right_leg.FormFactor = "Symmetric"
  1097. right_leg.Locked = true
  1098. right_leg.Name = "Right Leg"
  1099. right_leg.Size = Vector3.new(1, 2, 1)
  1100. right_leg.TopSurface = "Smooth"
  1101. left_leg.BrickColor = BrickColor.new("Br. yellowish green")
  1102. left_leg.BottomSurface = "Smooth"
  1103. left_leg.CanCollide = false
  1104. left_leg.CFrame = cframe * CFrame.new(-0.5, -2, 0)
  1105. left_leg.FormFactor = "Symmetric"
  1106. left_leg.Locked = true
  1107. left_leg.Name = "Left Leg"
  1108. left_leg.Size = Vector3.new(1, 2, 1)
  1109. left_leg.TopSurface = "Smooth"
  1110. neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  1111. neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  1112. neck.Name = "Neck"
  1113. neck.Part0 = torso
  1114. neck.Part1 = head
  1115. right_shoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1116. right_shoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1117. right_shoulder.MaxVelocity = 0.15
  1118. right_shoulder.Name = "Right Shoulder"
  1119. right_shoulder.Part0 = torso
  1120. right_shoulder.Part1 = right_arm
  1121. left_shoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1122. left_shoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1123. left_shoulder.MaxVelocity = 0.15
  1124. left_shoulder.Name = "Left Shoulder"
  1125. left_shoulder.Part0 = torso
  1126. left_shoulder.Part1 = left_arm
  1127. right_hip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1128. right_hip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1129. right_hip.MaxVelocity = 0.1
  1130. right_hip.Name = "Right Hip"
  1131. right_hip.Part0 = torso
  1132. right_hip.Part1 = right_leg
  1133. left_hip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1134. left_hip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1135. left_hip.MaxVelocity = 0.1
  1136. left_hip.Name = "Left Hip"
  1137. left_hip.Part0 = torso
  1138. left_hip.Part1 = left_leg
  1139. humanoid.Died:connect(function()
  1140. wait(5)
  1141. model:Destroy()
  1142. end)
  1143. model.Parent = parent
  1144. return model
  1145. end
  1146.  
  1147. Serializer = {};
  1148.  
  1149. Serializer.NAN = math.abs(0 / 0)
  1150.  
  1151. function Serializer.DecodeFloatArray(metadata_size, lookup, data, index)
  1152. local metadata_bytes = math.ceil(metadata_size * 0.25)
  1153. local metadata = {string.byte(data, index, index + metadata_bytes - 1)}
  1154. local components = {}
  1155. local start_index = index
  1156. index = index + metadata_bytes
  1157. for byte_index, byte in ipairs(metadata) do
  1158. local last_offset = 3
  1159. if byte_index == metadata_bytes then
  1160. last_offset = (metadata_size - 1) % 4
  1161. end
  1162. for value_offset = 0, last_offset do
  1163. local value_code = byte * 0.25 ^ value_offset % 4
  1164. value_code = value_code - value_code % 1
  1165. if value_code == 0 then
  1166. table.insert(components, Serializer.DecodeFloat32(string.byte(data, index, index + 3)))
  1167. index = index + 4
  1168. else
  1169. table.insert(components, lookup[value_code])
  1170. end
  1171. end
  1172. end
  1173. return components, index - start_index
  1174. end
  1175. function Serializer.EncodeFloatArray(values, common)
  1176. local lookup = {[common[1]] = 1, [common[2]] = 2, [common[3]] = 3}
  1177. local value_count = #values
  1178. local metadata_bytes = math.ceil(value_count * 0.25)
  1179. local metadata = {}
  1180. local buffer = {}
  1181. for byte_index = 1, metadata_bytes do
  1182. local last_offset = 3
  1183. if byte_index == metadata_bytes then
  1184. last_offset = (value_count - 1) % 4
  1185. end
  1186. local metadata_byte = 0
  1187. local offset_multiplier = 1
  1188. local byte_offset = (byte_index - 1) * 4 + 1
  1189. for value_offset = 0, last_offset do
  1190. local value_index = byte_offset + value_offset
  1191. local value = values[value_index]
  1192. local code = lookup[value] or 0
  1193. metadata_byte = metadata_byte + code * offset_multiplier
  1194. offset_multiplier = offset_multiplier * 4
  1195. if code == 0 then
  1196. table.insert(buffer, Serializer.EncodeFloat32(value))
  1197. end
  1198. end
  1199. metadata[byte_index] = string.char(metadata_byte)
  1200. end
  1201. return table.concat(metadata) .. table.concat(buffer)
  1202. end
  1203.  
  1204. function Serializer.DecodeColor3(data, index)
  1205. local components, size = Serializer.DecodeFloatArray(3, {0, 0.5, 1}, data, index)
  1206. return Color3.new(unpack(components)), size
  1207. end
  1208. function Serializer.DecodeFloat32(b0, b1, b2, b3)
  1209. local b2_low = b2 % 128
  1210. local mantissa = b0 + (b1 + b2_low * 256) * 256
  1211. local exponent = (b2 - b2_low) / 128 + b3 % 128 * 2
  1212. local number
  1213. if mantissa == 0 then
  1214. if exponent == 0 then
  1215. number = 0
  1216. elseif exponent == 0xFF then
  1217. number = math.huge
  1218. else
  1219. number = 2 ^ (exponent - 127)
  1220. end
  1221. elseif exponent == 255 then
  1222. number = Serializer.NAN
  1223. else
  1224. number = (1 + mantissa / 8388608) * 2 ^ (exponent - 127)
  1225. end
  1226. if b3 >= 128 then
  1227. return -number
  1228. else
  1229. return number
  1230. end
  1231. end
  1232. function Serializer.EncodeColor3(color3)
  1233. return Serializer.EncodeFloatArray({color3.r, color3.g, color3.b}, {0, 0.5, 1})
  1234. end
  1235. function Serializer.EncodeFloat32(number)
  1236. if number == 0 then
  1237. if 1 / number > 0 then
  1238. return "\0\0\0\0"
  1239. else
  1240. return "\0\0\0\128"
  1241. end
  1242. elseif number ~= number then
  1243. if string.sub(tostring(number), 1, 1) == "-" then
  1244. return "\255\255\255\255"
  1245. else
  1246. return "\255\255\255\127"
  1247. end
  1248. elseif number == math.huge then
  1249. return "\0\0\128\127"
  1250. elseif number == -math.huge then
  1251. return "\0\0\128\255"
  1252. else
  1253. local b3 = 0
  1254. if number < 0 then
  1255. number = -number
  1256. b3 = 128
  1257. end
  1258. local mantissa, exponent = math.frexp(number)
  1259. exponent = exponent + 126
  1260. if exponent < 0 then
  1261. return "\0\0\0" .. string.char(b3)
  1262. elseif exponent >= 255 then
  1263. return "\0\0\128" .. string.char(b3 + 0x7F)
  1264. else
  1265. local fraction = mantissa * 16777216 - 8388608 + 0.5
  1266. fraction = fraction - fraction % 1
  1267. local exponent_low = exponent % 2
  1268. local b0 = fraction % 256
  1269. local b1 = fraction % 65536
  1270. local b2 = (fraction - b1) / 65536 + exponent_low * 128
  1271. b1 = (b1 - b0) / 256
  1272. b3 = b3 + (exponent - exponent_low) / 2
  1273. return string.char(b0, b1, b2, b3)
  1274. end
  1275. end
  1276. end
  1277.  
  1278. LuaEnum = {};
  1279.  
  1280. LuaEnum.enum_metatable = {
  1281. __call = function(self, value)
  1282. local valueType = type(value)
  1283. if valueType == "table" and getmetatable(value) == LuaEnum.enum_item_metatable then
  1284. return value
  1285. else
  1286. return self[value]
  1287. end
  1288. end,
  1289. __index = function(self, key)
  1290. local enumItem = self.ItemsByName[key] or self.ItemsByValue[key]
  1291. if enumItem == nil then
  1292. local default = self.Default
  1293. if default then
  1294. Logger.printf("Warning", "%s is not a valid EnumItem, returning default (%s)", Utility.ToString(key), tostring(default))
  1295. enumItem = default
  1296. else
  1297. Logger.errorf(2, "%s is not a valid EnumItem", Utility.ToString(key))
  1298. end
  1299. end
  1300. return enumItem
  1301. end,
  1302. __tostring = function(self)
  1303. return self.Name
  1304. end
  1305. }
  1306. LuaEnum.enum_item_metatable = {
  1307. __tostring = function(self)
  1308. return self.Enum.Name .. "." .. self.Name
  1309. end
  1310. }
  1311. LuaEnum.init_metatable = {
  1312. __call = function(self, items)
  1313. local enumItemsByName = {}
  1314. local enumItemsByValue = {}
  1315. local enum = {
  1316. ItemsByName = enumItemsByName,
  1317. ItemsByValue = enumItemsByValue,
  1318. Name = self[1]
  1319. }
  1320. local default = items.Default
  1321. if default ~= nil then
  1322. items.Default = nil
  1323. end
  1324. for value, name in pairs(items) do
  1325. local enumItem = setmetatable({
  1326. Enum = enum,
  1327. Name = name,
  1328. Value = value
  1329. }, LuaEnum.enum_item_metatable)
  1330. enumItemsByName[name] = enumItem
  1331. enumItemsByValue[value] = enumItem
  1332. if name == default or value == default then
  1333. enum.Default = enumItem
  1334. end
  1335. end
  1336. return setmetatable(enum, LuaEnum.enum_metatable)
  1337. end
  1338. }
  1339. function LuaEnum.new(name)
  1340. return setmetatable({name}, LuaEnum.init_metatable)
  1341. end
  1342.  
  1343. Logger = {};
  1344.  
  1345. Logger.entries = {0}
  1346. Logger.MessageType = LuaEnum.new "MessageType" {
  1347. "Output",
  1348. "Info",
  1349. "Warning",
  1350. "Severe",
  1351. "Error",
  1352. Default = "Severe"
  1353. }
  1354. Logger.MESSAGE_TYPE_SETTINGS = {
  1355. { -- Output
  1356. Font = "Arial",
  1357. TextColor3 = Color3.new(0, 0, 0)
  1358. },
  1359. { -- Info
  1360. Font = "Arial",
  1361. TextColor3 = Color3.new(0, 0, 1)
  1362. },
  1363. { -- Warning
  1364. Font = "ArialBold",
  1365. TextColor3 = Color3.new(1, 0.5, 0)
  1366. },
  1367. { -- Severe/Error
  1368. Font = "ArialBold",
  1369. TextColor3 = Color3.new(1, 0, 0)
  1370. }
  1371. }
  1372. Logger.MAX_ENTRIES = 160
  1373. Logger.WARNING_TRACE_ITEM_COUNT = 5
  1374. Logger.rbxPrint = getfenv(RbxUtility.CreateSignal).print
  1375. function Logger.error(level, message)
  1376. message = message .. "\n" .. Logger.StackTraceToString(Logger.GenerateStackTrace(level + 1))
  1377. Logger.AddEntry {Logger.MessageType.Error, message}
  1378. error(level + 1, message)
  1379. end
  1380. function Logger.errorf(level, messageFormat, ...)
  1381. Logger.error(level + 1, string.format(messageFormat, ...))
  1382. end
  1383. function Logger.print(messageType, message, level)
  1384. messageType = Logger.MessageType(messageType)
  1385. local entry = {messageType, message}
  1386. Logger.rbxPrint(Logger.EntryToString(entry))
  1387. Logger.AddEntry(entry)
  1388. if level ~= false and messageType.Value >= Logger.MessageType.Warning.Value then
  1389. local maxItems
  1390. if messageType.Value >= Logger.MessageType.Severe.Value then
  1391. maxItems = math.huge
  1392. else
  1393. maxItems = Logger.WARNING_TRACE_ITEM_COUNT
  1394. end
  1395. local trace = Logger.GenerateStackTrace((level or 1) + 1, math.huge, 10, maxItems + 1)
  1396. local traceLength = #trace
  1397. local stackTraceMessage
  1398. local suffix = ""
  1399. if traceLength > maxItems then
  1400. trace[traceLength] = nil
  1401. suffix = "\n..."
  1402. end
  1403. Logger.print("Info", "Stack trace:\n" .. Logger.StackTraceToString(trace) .. suffix .. "\nStack end", false)
  1404. end
  1405. end
  1406. function Logger.printf(messageType, messageFormat, ...)
  1407. Logger.print(messageType, string.format(messageFormat, ...), 2)
  1408. end
  1409. function Logger.AddEntry(entry)
  1410. local entries = Logger.entries
  1411. if entries[1] >= Logger.MAX_ENTRIES then
  1412. local first = entries[2]
  1413. local nextFirst = first[2]
  1414. first[1] = nil
  1415. first[2] = nil
  1416. entries[1] = entries[1] - 1
  1417. entries[2] = nextFirst
  1418. if not nextFirst then
  1419. entries[3] = nil
  1420. end
  1421. end
  1422. local last = entries[3]
  1423. local node = {entry}
  1424. if last then
  1425. entries[3] = node
  1426. last[2] = node
  1427. else
  1428. entries[2] = node
  1429. entries[3] = node
  1430. end
  1431. entries[1] = entries[1] + 1
  1432. end
  1433. function Logger.NodeIterator(list, node)
  1434. if node then
  1435. node = node[2]
  1436. else
  1437. node = list[2]
  1438. end
  1439. if node then
  1440. return node, node[1]
  1441. end
  1442. end
  1443. function Logger.EntryToString(entry)
  1444. local messageType, message = entry[1], tostring(entry[2])
  1445. if messageType and messageType.Value >= Logger.MessageType.Info.Value then
  1446. return messageType.Name .. ": " .. message
  1447. else
  1448. return message
  1449. end
  1450. end
  1451. function Logger.GenerateStackTrace(level, maxLevel, maxTailCalls, maxTraceItems)
  1452. level = level + 2
  1453. if maxLevel == nil then
  1454. maxLevel = math.huge
  1455. else
  1456. maxLevel = maxLevel + 2
  1457. end
  1458. maxTailCalls = maxTailCalls or 10
  1459. maxTraceItems = maxTraceItems or math.huge
  1460. local trace = {}
  1461. local numTailCalls = 0
  1462. while level <= maxLevel and numTailCalls <= maxTailCalls and #trace < maxTraceItems do
  1463. local success, errorMessage = xpcall(function() error("-", level + 1) end, function(...) return ... end)
  1464. if errorMessage == "-" then
  1465. numTailCalls = numTailCalls + 1
  1466. else
  1467. if numTailCalls > 0 then
  1468. local traceSize = #trace
  1469. if traceSize > 0 then
  1470. trace[#trace][3] = numTailCalls
  1471. end
  1472. numTailCalls = 0
  1473. end
  1474. local script, line = string.match(errorMessage, "(.*):(%d+)")
  1475. trace[#trace + 1] = {script, tonumber(line), 0}
  1476. end
  1477. level = level + 1
  1478. end
  1479. return trace
  1480. end
  1481. function Logger.StackTraceToString(trace)
  1482. local buffer = {}
  1483. for _, data in ipairs(trace) do
  1484. buffer[#buffer + 1] = string.format("Script %q, line %d", data[1], data[2])
  1485. local numTailCalls = data[3]
  1486. if numTailCalls == 1 then
  1487. buffer[#buffer + 1] = "... 1 tail call"
  1488. elseif numTailCalls > 1 then
  1489. buffer[#buffer + 1] = string.format("... %d tail calls", numTailCalls)
  1490. end
  1491. end
  1492. return table.concat(buffer, "\n")
  1493. end
  1494. function Logger.MessageOutFunc(message, messageType)
  1495. if AdvancedGUI and AdvancedGUI.Print then
  1496. local messageTypeValue
  1497. if messageType == Enum.MessageType.MessageOutput then
  1498. local tagName, untaggedMessage = string.match(message, "(%a+): (.*)")
  1499. if tagName == "Info" or tagName == "Warning" or tagName == "Severe" then
  1500. messageTypeValue = Logger.MessageType[tagName].Value
  1501. message = untaggedMessage
  1502. else
  1503. messageTypeValue = Logger.MessageType.Output.Value
  1504. end
  1505. else
  1506. messageTypeValue = messageType.Value + 1
  1507. end
  1508. AdvancedGUI.PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], message)
  1509. end
  1510. end
  1511. function print(...)
  1512. local args = {...}
  1513. local buffer = {}
  1514. for index = 1, select("#", ...) do
  1515. buffer[index] = tostring(args[index])
  1516. end
  1517. local message = table.concat(buffer, "\t")
  1518. Logger.print("Output", message)
  1519. end
  1520.  
  1521. CharacterAppearance = {};
  1522.  
  1523. CharacterAppearance.defaultAppearanceId = 4
  1524. CharacterAppearance.stock = {}
  1525. function CharacterAppearance.Create(properties)
  1526. local id = properties.Id
  1527. local bodyColors = Instance.new("BodyColors")
  1528. bodyColors.HeadColor = properties.HeadColor
  1529. bodyColors.TorsoColor = properties.TorsoColor
  1530. bodyColors.RightArmColor = properties.RightArmColor
  1531. bodyColors.LeftArmColor = properties.LeftArmColor
  1532. bodyColors.RightLegColor = properties.RightLegColor
  1533. bodyColors.LeftLegColor = properties.LeftLegColor
  1534. local characterObjects = {bodyColors}
  1535. local headObjects = {}
  1536. local data = {
  1537. characterObjects = characterObjects,
  1538. headObjects = headObjects,
  1539. tshirt = properties.TShirt
  1540. }
  1541. for _, assetId in ipairs(properties.CharacterAssets) do
  1542. TaskScheduler.Start(CharacterAppearance.LoadAsset, characterObjects, assetId)
  1543. end
  1544. for _, assetId in ipairs(properties.HeadAssets) do
  1545. TaskScheduler.Start(CharacterAppearance.LoadAsset, headObjects, assetId)
  1546. end
  1547. CharacterAppearance.stock[id] = data
  1548. end
  1549. function CharacterAppearance.GetDefaultAppearance()
  1550. return CharacterAppearance.stock[CharacterAppearance.defaultAppearanceId]
  1551. end
  1552. function CharacterAppearance.LoadAsset(objects, assetId)
  1553. local asset = InsertService:LoadAsset(assetId)
  1554. for _, child in ipairs(asset:GetChildren()) do
  1555. child.Archivable = true
  1556. table.insert(objects, child:Clone())
  1557. end
  1558. end
  1559. CharacterAppearance.Create {
  1560. Id = 1,
  1561. HeadColor = BrickColor.new("Institutional white"),
  1562. TorsoColor = BrickColor.new("Institutional white"),
  1563. RightArmColor = BrickColor.new("Institutional white"),
  1564. LeftArmColor = BrickColor.new("Institutional white"),
  1565. RightLegColor = BrickColor.new("Institutional white"),
  1566. LeftLegColor = BrickColor.new("Institutional white"),
  1567. CharacterAssets = {
  1568. 90825058, 90825211,
  1569. 27112056, 27112052,
  1570. 27112039, 27112025,
  1571. 27112068, 38322996
  1572. },
  1573. HeadAssets = {
  1574. 20722130,
  1575. 8330576
  1576. }
  1577. }
  1578. CharacterAppearance.Create {
  1579. Id = 2,
  1580. HeadColor = BrickColor.new("Institutional white"),
  1581. TorsoColor = BrickColor.new("Institutional white"),
  1582. RightArmColor = BrickColor.new("Institutional white"),
  1583. LeftArmColor = BrickColor.new("Institutional white"),
  1584. RightLegColor = BrickColor.new("Institutional white"),
  1585. LeftLegColor = BrickColor.new("Institutional white"),
  1586. CharacterAssets = {
  1587. 90825058, 90825211,
  1588. 11748356, 1029025,
  1589. 1235488, 27112056,
  1590. 27112052, 27112039,
  1591. 27112025, 27112068
  1592. },
  1593. HeadAssets = {
  1594. 20722130
  1595. }
  1596. }
  1597. CharacterAppearance.Create {
  1598. Id = 3,
  1599. HeadColor = BrickColor.new("Pastel brown"),
  1600. TorsoColor = BrickColor.new("Pastel brown"),
  1601. RightArmColor = BrickColor.new("Pastel brown"),
  1602. LeftArmColor = BrickColor.new("Pastel brown"),
  1603. RightLegColor = BrickColor.new("White"),
  1604. LeftLegColor = BrickColor.new("White"),
  1605. CharacterAssets = {
  1606. 134289125, 48474356,
  1607. 100339040, 46302558,
  1608. 153955895
  1609. },
  1610. HeadAssets = {},
  1611. TShirt = "rbxassetid://148856353"
  1612. }
  1613. CharacterAppearance.Create {
  1614. Id = 4,
  1615. HeadColor = BrickColor.new("Pastel brown"),
  1616. TorsoColor = BrickColor.new("Pastel brown"),
  1617. RightArmColor = BrickColor.new("Pastel brown"),
  1618. LeftArmColor = BrickColor.new("Pastel brown"),
  1619. RightLegColor = BrickColor.new("White"),
  1620. LeftLegColor = BrickColor.new("White"),
  1621. CharacterAssets = {
  1622. 129458426, 96678344, 184489190
  1623. },
  1624. HeadAssets = {},
  1625. TShirt = "rbxassetid://160146697"
  1626. }
  1627.  
  1628. GraphicalEffects = {};
  1629.  
  1630. local MESH_IDS = {"rbxassetid://15310891"}
  1631. local SOUND_IDS = {"rbxassetid://2248511", "rbxassetid://1369158"}
  1632. local TEXTURE_IDS = {"rbxassetid://36527089", "rbxassetid://122610943", "rbxassetid://126561317", "rbxassetid://127033719"}
  1633. local preloadConnections = {}
  1634. local reloadingPreloads = false
  1635. function GraphicalEffects.InitPreloads()
  1636. local preload_part = Instance.new("Part")
  1637. GraphicalEffects.preload_part = preload_part
  1638. preload_part.Anchored = true
  1639. preload_part.Archivable = false
  1640. preload_part.BottomSurface = "Smooth"
  1641. preload_part.CanCollide = false
  1642. preload_part.CFrame = CFrame.new(math.huge, math.huge, math.huge)
  1643. preload_part.FormFactor = "Custom"
  1644. preload_part.Locked = true
  1645. preload_part.Name = "Asset Preloader"
  1646. preload_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1647. preload_part.TopSurface = "Smooth"
  1648. preload_part.Transparency = 1
  1649. preloadConnections[preload_part] = preload_part.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1650. for _, mesh_id in ipairs(MESH_IDS) do
  1651. local mesh = Instance.new("SpecialMesh")
  1652. mesh.MeshType = "FileMesh"
  1653. mesh.MeshId = mesh_id
  1654. preloadConnections[mesh] = mesh.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1655. mesh.Parent = preload_part
  1656. end
  1657. for _, sound_id in ipairs(SOUND_IDS) do
  1658. local sound = Instance.new("Sound")
  1659. sound.SoundId = sound_id
  1660. sound.Volume = 0
  1661. preloadConnections[sound] = sound.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1662. sound.Parent = preload_part
  1663. end
  1664. for _, texture_id in ipairs(TEXTURE_IDS) do
  1665. local decal = Instance.new("Decal")
  1666. decal.Texture = texture_id
  1667. preloadConnections[decal] = decal.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1668. decal.Parent = preload_part
  1669. end
  1670. preload_part.Parent = Workspace
  1671. end
  1672. function GraphicalEffects.PreloadsAncestryChanged(child, parent)
  1673. if not reloadingPreloads and parent ~= GraphicalEffects.preload_part and parent ~= Workspace then
  1674. reloadingPreloads = true
  1675. for _, connection in pairs(preloadConnections) do
  1676. connection:disconnect()
  1677. preloadConnections[_] = nil
  1678. end
  1679. wait(1)
  1680. reloadingPreloads = false
  1681. GraphicalEffects.InitPreloads()
  1682. end
  1683. end
  1684. GraphicalEffects.InitPreloads()
  1685. -- Hyper beam
  1686. function GraphicalEffects.FireSpaceHyperBeam(target, power, duration, radius, height, deviation)
  1687. local stepTime, gameTime = 1 / 30, TaskScheduler.GetCurrentTime()
  1688. local frames = duration * 30
  1689. local beamColorOffset = 0.75 * tick() -- math.random()
  1690. local blastPressure = power * 62500 + 250000
  1691. local beamPart = Instance.new("Part")
  1692. local beamMesh = Instance.new("SpecialMesh", beamPart)
  1693. local explosion = Instance.new("Explosion")
  1694. local sound = Instance.new("Sound", beamPart)
  1695. beamPart.Anchored = true
  1696. beamPart.CanCollide = false
  1697. beamPart.CFrame = CFrame.new(target, target + Vector3.new(deviation * (math.random() - 0.5), deviation * (math.random() - 0.5), height))
  1698. beamPart.FormFactor = "Custom"
  1699. beamPart.Locked = true
  1700. beamPart.Size = Vector3.new(0.2, 0.2, 0.2)
  1701. beamMesh.MeshId = "rbxassetid://15310891"
  1702. beamMesh.MeshType = "FileMesh"
  1703. beamMesh.TextureId = "rbxassetid://36527089"
  1704. local beamGlowPart1 = beamPart:Clone()
  1705. local beamGlowMesh1 = beamMesh:Clone()
  1706. local beamGlowPart2 = beamPart:Clone()
  1707. local beamGlowMesh2 = beamMesh:Clone()
  1708. local beamLight = Instance.new("PointLight", beamPart)
  1709. beamLight.Range = power * 2
  1710. beamLight.Shadows = true
  1711. explosion.BlastPressure = blastPressure
  1712. explosion.BlastRadius = power
  1713. explosion.Position = target
  1714. sound.SoundId = "rbxassetid://2248511"
  1715. sound.Volume = 1
  1716. local explosionHitConnection = explosion.Hit:connect(function(part, distance)
  1717. if not part.Anchored and part:GetMass() < power * power then
  1718. pcall(part.BreakJoints, part)
  1719. part.Color = Color3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  1720. end
  1721. end)
  1722. beamPart.Transparency = 0.5
  1723. beamPart.Archivable = false
  1724. beamGlowPart1.Transparency = 0.75
  1725. beamGlowPart2.Transparency = 0.75
  1726. beamGlowMesh1.Parent = beamGlowPart1
  1727. beamGlowPart1.Parent = beamPart
  1728. beamGlowMesh2.Parent = beamGlowPart2
  1729. beamGlowPart2.Parent = beamPart
  1730. beamPart.Parent = workspace
  1731. explosion.Parent = workspace
  1732. for frame = 1, frames do
  1733. local progress = frame / frames
  1734. local alpha = 1 - math.sin(0.5 * math.pi * progress)
  1735. local scale = 0.4 * alpha
  1736. local glowScale1 = alpha * (0.5 + 0.5 * math.sin(math.tau * (8 * gameTime + beamColorOffset)))
  1737. local glowScale2 = alpha * (0.5 + 0.5 * math.cos(math.tau * (8 * gameTime + beamColorOffset)))
  1738. local vertexColor = Vector3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  1739. beamLight.Brightness = 1 - progress
  1740. beamLight.Color = Color3.new(vertexColor.x, vertexColor.y, vertexColor.z)
  1741. beamMesh.Scale = Vector3.new(radius * scale, 9000, radius * scale)
  1742. beamMesh.VertexColor = vertexColor
  1743. beamGlowMesh1.Scale = Vector3.new(1.2 * radius * glowScale1, 9000, 1.2 * radius * glowScale1)
  1744. beamGlowMesh1.VertexColor = vertexColor
  1745. beamGlowMesh2.Scale = Vector3.new(1.2 * radius * glowScale2, 9000, 1.2 * radius * glowScale2)
  1746. beamGlowMesh2.VertexColor = vertexColor
  1747. RunService.Stepped:wait()
  1748. gameTime = TaskScheduler.GetCurrentTime()
  1749. if frame <= 2 then
  1750. local explosion = Instance.new("Explosion")
  1751. explosion.BlastPressure = (1 - progress) * blastPressure
  1752. explosion.BlastRadius = (1 - progress) * power
  1753. explosion.Position = target
  1754. explosion.Parent = Workspace
  1755. if frame == 2 then
  1756. sound:Play()
  1757. end
  1758. end
  1759. end
  1760. pcall(beamPart.Destroy, beamPart)
  1761. explosionHitConnection:disconnect()
  1762. end
  1763. function GraphicalEffects.SpaceHyperBeam(target, power, duration, radius, height, deviation)
  1764. TaskScheduler.Start(GraphicalEffects.FireSpaceHyperBeam, target, power or 12, duration or 1.5, radius or 6, height or 600, deviation or 20)
  1765. end
  1766.  
  1767. function GraphicalEffects.CrystalRing(data)
  1768. data = data or {}
  1769. local crystal_count = data.crystal_count or 10
  1770. local crystal_color = data.crystal_color or BrickColor.new("Bright red")
  1771. local crystal_scale = data.crystal_scale or Vector3.new(2 / 3, 2, 2 / 3)
  1772. local fade_out_color = data.fade_out_color or BrickColor.new("Really black")
  1773. local radius = radius or 1.25 * crystal_count / math.pi
  1774. local spawn_duration = data.spawn_duration or 0.065
  1775. local full_spawn_duration = spawn_duration * crystal_count
  1776. local float_duration = data.float_duration or 5
  1777. local wave_amplitude = data.wave_amplitude or 0.5
  1778. local wave_period = data.wave_period or 1
  1779. local appear_duration = data.appear_duration or 0.1
  1780. local disappear_duration = data.disappear_duration or 0.5
  1781. local base_part = data.base_part
  1782. local offset_cframe
  1783. if data.position then
  1784. offset_cframe = CFrame.new(data.position)
  1785. if base_part then
  1786. offset_cframe = base_part.CFrame:toObjectSpace(offset_cframe)
  1787. end
  1788. else
  1789. offset_cframe = CFrame.new()
  1790. end
  1791. local crystal_template = Instance.new("Part")
  1792. crystal_template.Anchored = true
  1793. crystal_template.Locked = true
  1794. crystal_template.CanCollide = false
  1795. crystal_template.BottomSurface = "Smooth"
  1796. crystal_template.TopSurface = "Smooth"
  1797. crystal_template.BrickColor = crystal_color
  1798. crystal_template.FormFactor = "Symmetric"
  1799. crystal_template.Size = Vector3.new(1, 1, 1)
  1800. local crystal_light = Instance.new("PointLight", crystal_template)
  1801. crystal_light.Brightness = 0.1 / crystal_count
  1802. crystal_light.Color = crystal_color.Color
  1803. crystal_light.Name = "Light"
  1804. crystal_light.Range = radius
  1805. crystal_light.Shadows = true
  1806. local crystal_mesh = Instance.new("SpecialMesh", crystal_template)
  1807. crystal_mesh.MeshId = "rbxassetid://9756362"
  1808. crystal_mesh.MeshType = "FileMesh"
  1809. crystal_mesh.Name = "Mesh"
  1810. crystal_mesh.Scale = crystal_scale
  1811. local crystal_model = Instance.new("Model")
  1812. crystal_model.Archivable = false
  1813. crystal_model.Name = "Crystal Model"
  1814. crystal_model.Parent = Workspace
  1815. local crystals = {}
  1816. local lights = {}
  1817. local meshes = {}
  1818. for index = 1, crystal_count do
  1819. local crystal = crystal_template:Clone()
  1820. crystal.Parent = crystal_model
  1821. crystals[index] = crystal
  1822. lights[index] = crystal.Light
  1823. meshes[index] = crystal.Mesh
  1824. end
  1825. local start_time = tick()
  1826. repeat
  1827. local base_cframe = offset_cframe
  1828. if base_part then
  1829. base_cframe = base_part.CFrame * base_cframe
  1830. end
  1831. local elapsed_time = tick() - start_time
  1832. for index, crystal in ipairs(crystals) do
  1833. local crystal_time = elapsed_time - index * spawn_duration
  1834. local disappear_time = crystal_time - float_duration
  1835. local offset
  1836. if crystal_time < 0 then
  1837. offset = 0
  1838. elseif crystal_time < appear_duration then
  1839. offset = radius * crystal_time / appear_duration
  1840. else
  1841. offset = radius
  1842. end
  1843. local wave_offset
  1844. if disappear_time >= 0 then
  1845. local disappear_progress = disappear_time / disappear_duration
  1846. if disappear_progress > 1 then
  1847. if crystal.Parent then
  1848. crystal:Destroy()
  1849. end
  1850. else
  1851. local inverse_progress = 1 - disappear_progress
  1852. local light = lights[index]
  1853. local mesh = meshes[index]
  1854. crystal.BrickColor = fade_out_color
  1855. light.Brightness = 2 * inverse_progress
  1856. light.Range = 2 * radius
  1857. mesh.Scale = crystal_scale * inverse_progress
  1858. end
  1859. wave_offset = 0
  1860. else
  1861. wave_offset = wave_amplitude * math.sin(math.tau * (elapsed_time - index / crystal_count * 3) / wave_period)
  1862. end
  1863. local rotation_angle = (tick() * 0.5 + (index - 1) / crystal_count) % 1 * math.tau
  1864. crystal.CFrame = base_cframe * CFrame.Angles(0, rotation_angle, 0) * CFrame.new(0, wave_offset, -offset)
  1865. end
  1866. RunService.Stepped:wait()
  1867. until elapsed_time >= float_duration + full_spawn_duration + disappear_duration
  1868. if crystal_model.Parent then
  1869. crystal_model:Destroy()
  1870. end
  1871. end
  1872.  
  1873. GraphicalEffects.magicCircleData = {}
  1874. GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET = 6.25
  1875. function GraphicalEffects.AnimateMagicCircle(data)
  1876. local frame, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, duration,
  1877.  
  1878. stay, magic_circle_adornee_func, magic_circle_offset = unpack(data)
  1879. frame = frame + 1
  1880. data[1] = frame
  1881. local transparency = (frame / duration) ^ stay
  1882. local opacity = 1 - transparency
  1883. if frame == duration then
  1884. pcall(Game.Destroy, magic_circle_model)
  1885. GraphicalEffects.magicCircleData[data] = nil
  1886. else
  1887. if magic_circle_model.Parent ~= Workspace then
  1888. pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
  1889. end
  1890. local magic_circle_adornee = magic_circle_adornee_func()
  1891. magic_circle_position = magic_circle_adornee.Position + direction * magic_circle_offset
  1892. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
  1893.  
  1894. 25)
  1895. magic_circle_part.CFrame = magic_circle_cframe
  1896. magic_circle_light.Brightness = opacity
  1897. magic_circle_decal_back.Transparency = transparency
  1898. magic_circle_decal_front.Transparency = transparency
  1899. end
  1900. end
  1901. function GraphicalEffects.CreateMagicCircle(target, magic_circle_scale, magic_circle_image, light_color, duration, stay, magic_circle_adornee_func,
  1902.  
  1903. magic_circle_offset)
  1904. local magic_circle_adornee = magic_circle_adornee_func()
  1905. if magic_circle_adornee then
  1906. local origin = magic_circle_adornee.Position
  1907. local direction = (target - origin).unit
  1908. local magic_circle_position = origin + direction * magic_circle_offset
  1909. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  1910. local magic_circle_model = Instance.new("Model")
  1911. local magic_circle_part = Instance.new("Part", magic_circle_model)
  1912. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  1913. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  1914. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  1915. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  1916. magic_circle_model.Archivable = false
  1917. magic_circle_part.Anchored = true
  1918. magic_circle_part.BottomSurface = "Smooth"
  1919. magic_circle_part.CanCollide = false
  1920. magic_circle_part.CFrame = magic_circle_cframe
  1921. magic_circle_part.FormFactor = "Custom"
  1922. magic_circle_part.Locked = true
  1923. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1924. magic_circle_part.TopSurface = "Smooth"
  1925. magic_circle_part.Transparency = 1
  1926. magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  1927. magic_circle_light.Color = light_color
  1928. magic_circle_light.Range = 16 * magic_circle_scale
  1929. magic_circle_light.Shadows = true
  1930. magic_circle_decal_back.Face = "Back"
  1931. magic_circle_decal_back.Texture = magic_circle_image
  1932. magic_circle_decal_front.Face = "Front"
  1933. magic_circle_decal_front.Texture = magic_circle_image
  1934. magic_circle_model.Parent = Workspace
  1935. local data = {0, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front,
  1936.  
  1937. duration, stay, magic_circle_adornee_func, magic_circle_offset}
  1938. GraphicalEffects.magicCircleData[data] = true
  1939. return data
  1940. end
  1941. end
  1942.  
  1943. GraphicalEffects.missileData = {}
  1944. GraphicalEffects.missileParts = {}
  1945. function GraphicalEffects.AnimateMissile(data)
  1946. local frame, missilePart, targetPart, timeCreated, direction, touchedConnection, explodeRequested, bodyGyro, swooshSound, magicCircleData, lifeTime,
  1947.  
  1948. pointOnPart, flipped = unpack(data)
  1949. frame = frame + 1
  1950. data[1] = frame
  1951. if flipped then
  1952. direction = -direction
  1953. end
  1954. if frame <= 10 then
  1955. if frame == 2 then
  1956. swooshSound:Play()
  1957. end
  1958. missilePart.Anchored = true
  1959. local progress = frame / 10
  1960. missilePart.Size = Vector3.new(1, 1, progress * 4)
  1961. local magicCirclePart = magicCircleData[4]
  1962. local magicCirclePosition = magicCirclePart.Position
  1963. local missileOffset = 2 * progress * direction
  1964. local missilePosition = magicCirclePosition + missileOffset
  1965. missilePart.CFrame = CFrame.new(missilePosition, missilePosition + direction)
  1966. --missilePart.Transparency = 0.5 * (1 - progress)
  1967. if frame == 10 then
  1968. touchedConnection = missilePart.Touched:connect(function(hit)
  1969. if hit.CanCollide and hit.Parent and not GraphicalEffects.missileParts[hit] then
  1970. touchedConnection:disconnect()
  1971. data[7] = true
  1972. end
  1973. end)
  1974. data[6] = touchedConnection
  1975. end
  1976. else
  1977. missilePart.Anchored = false
  1978. local missilePosition = missilePart.Position
  1979. local targetPosition = targetPart.CFrame * pointOnPart
  1980. local distanceVector = targetPosition - missilePosition
  1981. local elapsedTime = time() - timeCreated
  1982. local targetParent = targetPart.Parent
  1983. if explodeRequested or (targetParent and distanceVector.magnitude < 10) or elapsedTime > lifeTime then
  1984. GraphicalEffects.missileData[data] = nil
  1985. GraphicalEffects.missileParts[missilePart] = nil
  1986. touchedConnection:disconnect()
  1987. if missilePart.Parent then
  1988. missilePart:Destroy()
  1989. local explosion = Instance.new("Explosion")
  1990. explosion.BlastRadius = 12.5
  1991. explosion.Position = missilePosition
  1992. local explosionHitConnection = explosion.Hit:connect(function(hit, distance)
  1993. local missileData = GraphicalEffects.missileParts[hit]
  1994. if missileData and distance < 3 then
  1995. missileData[7] = true
  1996. else
  1997. pcall(hit.BreakJoints, hit)
  1998. end
  1999. end)
  2000. explosion.Parent = Workspace
  2001. TaskScheduler.Schedule(1, explosionHitConnection.disconnect, explosionHitConnection)
  2002. end
  2003. else
  2004. local targetInWorkspace = targetPart:IsDescendantOf(Workspace)
  2005. if targetInWorkspace then
  2006. direction = distanceVector.unit
  2007. data[5] = direction
  2008. end
  2009. local speed = 14 + elapsedTime * 10
  2010. local gyroD
  2011. if elapsedTime < 42.5 and targetInWorkspace then
  2012. gyroD = 1000 - elapsedTime * 15
  2013. else
  2014. gyroD = 100
  2015. bodyGyro.maxTorque = Vector3.new(0, 0, 0)
  2016. if elapsedTime + 7.5 < lifeTime then
  2017. data[11] = elapsedTime + 7.5
  2018. end
  2019. end
  2020. bodyGyro.D = gyroD
  2021. bodyGyro.cframe = CFrame.new(Vector3.new(), direction)
  2022. missilePart.Velocity = missilePart.CFrame.lookVector * speed
  2023. end
  2024. end
  2025. end
  2026. function GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction, magic_circle_adornee_func, magic_circle_offset, flipped)
  2027. if not magic_circle_offset then
  2028. magic_circle_offset = GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET
  2029. end
  2030. local targetPosition = targetPart.Position
  2031. local headPosition = chatAdornee.Position
  2032. local origin = CFrame.new(headPosition, headPosition + direction) + direction * magic_circle_offset
  2033. local missilePart = Instance.new("Part")
  2034. local antiGravityForce = Instance.new("BodyForce", missilePart)
  2035. local bodyGyro = Instance.new("BodyGyro", missilePart)
  2036. local explosionSound = Instance.new("Sound", missilePart)
  2037. local swooshSound = Instance.new("Sound", missilePart)
  2038. antiGravityForce.force = Vector3.new(0, 196.2 * 4, 0)
  2039. bodyGyro.D = 1000
  2040. bodyGyro.maxTorque = Vector3.new(1, 1, 1)
  2041. explosionSound.PlayOnRemove = true
  2042. explosionSound.SoundId = "rbxasset://sounds/collide.wav"
  2043. explosionSound.Volume = 1
  2044. missilePart.Anchored = true
  2045. missilePart.BackSurface = "Studs"
  2046. missilePart.BottomSurface = "Studs"
  2047. missilePart.BrickColor = BrickColor.Red()
  2048. missilePart.CFrame = origin
  2049. missilePart.FormFactor = "Custom"
  2050. missilePart.FrontSurface = "Studs"
  2051. missilePart.LeftSurface = "Studs"
  2052. missilePart.Locked = true
  2053. missilePart.RightSurface = "Studs"
  2054. missilePart.Size = Vector3.new(1, 1, 0.2)
  2055. missilePart.TopSurface = "Studs"
  2056. --missilePart.Transparency = 0.5
  2057. swooshSound.Looped = true
  2058. swooshSound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  2059. swooshSound.Volume = 0.7
  2060. local magicCircleData = GraphicalEffects.CreateMagicCircle(headPosition + direction * 1000, 0.875, "rbxassetid://127033719", Color3.new(1, 1, 1),
  2061.  
  2062. 40, 4, magic_circle_adornee_func or function() return chatAdornee end, magic_circle_offset)
  2063. local data = {0, missilePart, targetPart, time(), direction, false, false, bodyGyro, swooshSound, magicCircleData, 50, pointOnPart, flipped}
  2064. missilePart.Parent = Workspace
  2065. GraphicalEffects.missileData[data] = true
  2066. GraphicalEffects.missileParts[missilePart] = data
  2067. end
  2068.  
  2069. function GraphicalEffects.CubicInterpolate(y0, y1, y2, y3, mu)
  2070. local a0, a1, a2, a3, mu2
  2071. mu2 = mu * mu
  2072. a0 = y3 - y2 - y0 + y1
  2073. a1 = y0 - y1 - a0
  2074. a2 = y2 - y0
  2075. a3 = y1
  2076. return a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3
  2077. end
  2078. function GraphicalEffects.JointCrap(model, cycletime)
  2079. if model then
  2080. local cycletime = cycletime or (0.75 * (1 + math.random() * 4))
  2081. local offsetradius = 0.75
  2082. local rotationoffset = math.pi
  2083. local joints = {}
  2084. local stack = model:GetChildren()
  2085. while #stack ~= 0 do
  2086. local object = stack[#stack]
  2087. table.remove(stack)
  2088. for index, child in ipairs(object:GetChildren()) do
  2089. table.insert(stack, child)
  2090. end
  2091. if object:IsA("JointInstance") then
  2092. table.insert(joints, object)
  2093. end
  2094. end
  2095. local rot0 = {}
  2096. local rot1 = {}
  2097. local rot2 = {}
  2098. local rot3 = {}
  2099. local rot4 = {}
  2100. for index, joint in ipairs(joints) do
  2101. local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  2102. local rot = Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  2103. rot0[index] = {joint.C0, joint.C1}
  2104. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  2105. rot2[index] = {pos, rot}
  2106. pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  2107. rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  2108. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  2109. rot3[index] = {pos, rot}
  2110. pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  2111. rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  2112. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  2113. rot4[index] = {pos, rot}
  2114. end
  2115. while model.Parent do
  2116. for i, j in ipairs(joints) do
  2117. local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  2118. local rot = rot4[i][2] + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  2119. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  2120. rot1[i], rot2[i], rot3[i], rot4[i] = rot2[i], rot3[i], rot4[i], {pos, rot}
  2121. end
  2122. local start = tick()
  2123. while true do
  2124. local ctime = tick()
  2125. local elapsed = ctime - start
  2126. if elapsed > cycletime then
  2127. break
  2128. end
  2129. local progress = elapsed / cycletime
  2130. for index, joint in ipairs(joints) do
  2131. local v0, v1, v2, v3, v4 = rot0[index], rot1[index], rot2[index], rot3[index], rot4[index]
  2132. local p1, p2, p3, p4, r1, r2, r3, r4 = v1[1], v2[1], v3[1], v4[1], v1[2], v2[2], v3[2], v4[2]
  2133. local px = GraphicalEffects.CubicInterpolate(p1.x, p2.x, p3.x, p4.x, progress)
  2134. local py = GraphicalEffects.CubicInterpolate(p1.y, p2.y, p3.y, p4.y, progress)
  2135. local pz = GraphicalEffects.CubicInterpolate(p1.z, p2.z, p3.z, p4.z, progress)
  2136. local rx = GraphicalEffects.CubicInterpolate(r1.x, r2.x, r3.x, r4.x, progress)
  2137. local ry = GraphicalEffects.CubicInterpolate(r1.y, r2.y, r3.y, r4.y, progress)
  2138. local rz = GraphicalEffects.CubicInterpolate(r1.z, r2.z, r3.z, r4.z, progress)
  2139. local cframe = CFrame.new(px, py, pz) * CFrame.Angles(rx, ry, rz)
  2140. joint.C0 = v0[1] * cframe
  2141. joint.C1 = v0[2] * cframe:inverse()
  2142. end
  2143. RunService.Stepped:wait()
  2144. end
  2145. end
  2146. end
  2147. end
  2148.  
  2149. GraphicalEffects.LASER_WIDTH = 0.15
  2150. GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE = 6.25
  2151. GraphicalEffects.laser_data = {}
  2152. --GraphicalEffects.fragmentation = {}
  2153. function GraphicalEffects.AnimateLaserOfDeath(data)
  2154. local frame, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part, magic_circle_light,
  2155.  
  2156. magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay, light_effects =
  2157.  
  2158. unpack(data)
  2159. local laser_color = laser_part.Color
  2160. frame = frame + 1
  2161. data[1] = frame
  2162. local transparency = (frame / duration) ^ stay
  2163. local opacity = 1 - transparency
  2164. if frame == 2 then
  2165. sound:Play()
  2166. end
  2167. if frame == duration then
  2168. pcall(Game.Destroy, magic_circle_model)
  2169. GraphicalEffects.laser_data[data] = nil
  2170. else
  2171. if magic_circle_model.Parent ~= Workspace then
  2172. pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
  2173. end
  2174. local laser_distance = 0
  2175. local origin = chatAdornee.CFrame
  2176. if not light_effects then
  2177. direction = (origin * directionOrientation - origin.p).unit
  2178. end
  2179. local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  2180. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
  2181.  
  2182. 25)
  2183. local loop_scale = (laser_scale - 1) / 10
  2184. for x_offset = -loop_scale, loop_scale, 2 do
  2185. for y_offset = -loop_scale, loop_scale, 2 do
  2186. local origin_position = magic_circle_cframe * Vector3.new(x_offset, y_offset, 0)
  2187. for index = 1, 8 do
  2188. local part, position
  2189. for ray_index = 1, 10 do
  2190. local ray = Ray.new(origin_position + direction * (999 * (ray_index - 1)), direction * 999)
  2191. part, position = Workspace:FindPartOnRay(ray, magic_circle_model)
  2192. if part then
  2193. break
  2194. end
  2195. end
  2196. if part then
  2197. laser_distance = (position - origin_position).magnitude
  2198. if frame % 8 == 1 and index == 1 then
  2199. Instance.new("Explosion", Workspace).Position = position
  2200. end
  2201. if not part:IsA("Terrain") then
  2202. pcall(part.BreakJoints, part)
  2203. local is_block = part:IsA("Part") and part.Shape == Enum.PartType.Block
  2204. local mass = part:GetMass()
  2205. local size = part.Size
  2206. if (is_block and ((size.X < fragmentation_size and size.Y < fragmentation_size and size.Z <
  2207.  
  2208. fragmentation_size) or (not part.Anchored and mass < 750))) or (not is_block and mass < 250000) then
  2209. local part_transparency = math.max(part.Transparency + 0.007 * fragmentation_size, 0.5)
  2210. if part_transparency >= 0.5 then -- temporarily to minimize debris
  2211. pcall(Game.Destroy, part)
  2212. else
  2213. local cframe = part.CFrame
  2214. part.Anchored = false
  2215. part.BrickColor = BrickColor.new("Medium stone grey")
  2216. part.CanCollide = true
  2217. if part:IsA("FormFactorPart") then
  2218. part.FormFactor = "Custom"
  2219. end
  2220. part.Size = size - Vector3.new(0.135, 0.135, 0.135) * fragmentation_size
  2221. part.Transparency = part_transparency
  2222. part.CFrame = cframe + direction * 5
  2223. part.Velocity = part.Velocity + direction * 40
  2224. end
  2225. elseif is_block then
  2226. local parts = {part}
  2227. local model = Instance.new("Model", part.Parent)
  2228. model.Name = "Fragments"
  2229. if size.X >= fragmentation_size then
  2230. size = Vector3.new(0.5, 1, 1) * size
  2231. local archivable = part.Archivable
  2232. local cframe = part.CFrame
  2233. part.FormFactor = "Custom"
  2234. part.Size = size
  2235. part.Archivable = true
  2236. local part_clone = part:Clone()
  2237. part.Archivable = archivable
  2238. part_clone.Archivable = archivable
  2239. part.CFrame = cframe * CFrame.new(-0.5 * size.X, 0, 0)
  2240. part_clone.CFrame = cframe * CFrame.new(0.5 * size.X, 0, 0)
  2241. part_clone.Parent = model
  2242. parts[2] = part_clone
  2243. end
  2244. if size.Y >= fragmentation_size then
  2245. size = Vector3.new(1, 0.5, 1) * size
  2246. for part_index = 1, #parts do
  2247. local part = parts[part_index]
  2248. local archivable = part.Archivable
  2249. local cframe = part.CFrame
  2250. part.FormFactor = "Custom"
  2251. part.Size = size
  2252. part.Archivable = true
  2253. local part_clone = part:Clone()
  2254. part.Archivable = archivable
  2255. part_clone.Archivable = archivable
  2256. part.CFrame = cframe * CFrame.new(0, -0.5 * size.Y, 0)
  2257. part_clone.CFrame = cframe * CFrame.new(0, 0.5 * size.Y, 0)
  2258. part_clone.Parent = model
  2259. table.insert(parts, part_clone)
  2260. end
  2261. end
  2262. if size.Z >= fragmentation_size then
  2263. size = Vector3.new(1, 1, 0.5) * size
  2264. for part_index = 1, #parts do
  2265. local part = parts[part_index]
  2266. local archivable = part.Archivable
  2267. local cframe = part.CFrame
  2268. part.FormFactor = "Custom"
  2269. part.Size = size
  2270. part.Archivable = true
  2271. local part_clone = part:Clone()
  2272. part.Archivable = archivable
  2273. part_clone.Archivable = archivable
  2274. part.CFrame = cframe * CFrame.new(0, 0, -0.5 * size.Z)
  2275. part_clone.CFrame = cframe * CFrame.new(0, 0, 0.5 * size.Z)
  2276. part_clone.Parent = model
  2277. table.insert(parts, part_clone)
  2278. end
  2279. end
  2280. for _, part in ipairs(parts) do
  2281. part:MakeJoints()
  2282. end
  2283. else
  2284. break
  2285. end
  2286. end
  2287. else
  2288. laser_distance = 9990
  2289. break
  2290. end
  2291. end
  2292. end
  2293. end
  2294. local laser_cframe = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  2295. local laser_width = GraphicalEffects.LASER_WIDTH * opacity * laser_scale
  2296. local laser_mesh_offset = Vector3.new(0, 0.5 * laser_distance, 0)
  2297. laser_part.CFrame = laser_cframe
  2298. if laser_effects then
  2299. local laser_effect_data_1, laser_effect_data_2 = laser_effects[1], laser_effects[2]
  2300. local laser_effect_1, laser_effect_mesh_1 = laser_effect_data_1[1], laser_effect_data_1[2]
  2301. local laser_effect_2, laser_effect_mesh_2 = laser_effect_data_2[1], laser_effect_data_2[2]
  2302. laser_effect_1.CFrame = laser_cframe
  2303. laser_effect_2.CFrame = laser_cframe
  2304. laser_effect_mesh_1.Offset = laser_mesh_offset
  2305. laser_effect_mesh_2.Offset = laser_mesh_offset
  2306. local game_time = time()
  2307. local effect_scale_1 = 0.5 + 0.5 * math.sin(16 * math.pi * game_time)
  2308. local effect_scale_2 = 0.5 + 0.5 * math.cos(16 * math.pi * game_time)
  2309. laser_effect_mesh_1.Scale = 5 * Vector3.new(laser_width * effect_scale_1, laser_distance, laser_width * effect_scale_1)
  2310. laser_effect_mesh_2.Scale = 5 * Vector3.new(laser_width * effect_scale_2, laser_distance, laser_width * effect_scale_2)
  2311. laser_width = laser_width * 0.25
  2312. end
  2313. laser_mesh.Offset = laser_mesh_offset
  2314. laser_mesh.Scale = 5 * Vector3.new(laser_width, laser_distance, laser_width)
  2315. magic_circle_part.CFrame = magic_circle_cframe
  2316. magic_circle_light.Brightness = opacity
  2317. magic_circle_decal_back.Transparency = transparency
  2318. magic_circle_decal_front.Transparency = transparency
  2319. if light_effects then
  2320. for index, data in ipairs(laser_lights) do
  2321. local laser_spotlight_part, laser_spotlight = data[1], data[2]
  2322. local laser_spotlight_offset = 30 * (index - 1)
  2323. if laser_spotlight_offset <= laser_distance then
  2324. laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -laser_spotlight_offset)
  2325. laser_spotlight.Brightness = opacity
  2326. laser_spotlight.Enabled = true
  2327. else
  2328. laser_spotlight.Enabled = false
  2329. end
  2330. end
  2331. end
  2332. end
  2333. end
  2334. function GraphicalEffects.ShootLaserOfDeath(target, data)
  2335. if chatAdornee then
  2336. data = data or {}
  2337. local brickcolor = data.brickcolor or BrickColor.new("Really black")
  2338. local duration = data.duration or 40
  2339. local fragmentation_size = data.fragmentation_size or 3
  2340. local laser_scale = data.laser_scale or 1
  2341. local light_color = data.light_color or Color3.new(1, 0.5, 1)
  2342. local magic_circle_image = data.magic_circle_image or "rbxassetid://122610943"
  2343. local magic_circle_scale = data.magic_circle_scale or 1
  2344. local sound_volume = data.sound_volume or 1 / 3
  2345. local special_effects = data.special_effects
  2346. local stay = data.stay or 4
  2347. local origin = chatAdornee.CFrame
  2348. local directionOrientation = origin:pointToObjectSpace(target)
  2349. local direction = (target - origin.p).unit
  2350. local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  2351. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  2352. local magic_circle_model = Instance.new("Model")
  2353. local laser_part = Instance.new("Part", magic_circle_model)
  2354. local laser_mesh = Instance.new("CylinderMesh", laser_part)
  2355. local magic_circle_part = Instance.new("Part", magic_circle_model)
  2356. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  2357. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  2358. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  2359. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  2360. local sound = Instance.new("Sound", magic_circle_part)
  2361. sound.Pitch = 1.25
  2362. sound.SoundId = "rbxassetid://2248511"
  2363. sound.Volume = sound_volume
  2364. magic_circle_model.Archivable = false
  2365. laser_part.Anchored = true
  2366. laser_part.BottomSurface = "Smooth"
  2367. laser_part.BrickColor = brickcolor
  2368. laser_part.CanCollide = false
  2369. laser_part.CFrame = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  2370. laser_part.FormFactor = "Custom"
  2371. laser_part.Locked = true
  2372. laser_part.Size = Vector3.new(0.2, 0.2, 0.2)
  2373. laser_part.TopSurface = "Smooth"
  2374. laser_mesh.Offset = Vector3.new(0, 0, 0)
  2375. laser_mesh.Name = "Mesh"
  2376. laser_mesh.Scale = 5 * laser_scale * Vector3.new(GraphicalEffects.LASER_WIDTH, 0, GraphicalEffects.LASER_WIDTH)
  2377. magic_circle_part.Anchored = true
  2378. magic_circle_part.BottomSurface = "Smooth"
  2379. magic_circle_part.CanCollide = false
  2380. magic_circle_part.CFrame = magic_circle_cframe
  2381. magic_circle_part.FormFactor = "Custom"
  2382. magic_circle_part.Locked = true
  2383. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  2384. magic_circle_part.TopSurface = "Smooth"
  2385. magic_circle_part.Transparency = 1
  2386. magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  2387. magic_circle_light.Color = light_color
  2388. magic_circle_light.Range = 16 * magic_circle_scale
  2389. magic_circle_light.Shadows = true
  2390. magic_circle_decal_back.Face = "Back"
  2391. magic_circle_decal_back.Texture = magic_circle_image
  2392. magic_circle_decal_front.Face = "Front"
  2393. magic_circle_decal_front.Texture = magic_circle_image
  2394. magic_circle_model.Parent = Workspace
  2395. local laser_color = brickcolor.Color
  2396. local laser_lights = {}
  2397. local light_effects = laser_color.r + laser_color.g + laser_color.b > 0.25
  2398. if light_effects then
  2399. local laser_spotlight_part_template = Instance.new("Part")
  2400. local laser_spotlight_light_template = Instance.new("SpotLight", laser_spotlight_part_template)
  2401. laser_spotlight_part_template.Anchored = true
  2402. laser_spotlight_part_template.Anchored = true
  2403. laser_spotlight_part_template.BottomSurface = "Smooth"
  2404. laser_spotlight_part_template.CanCollide = false
  2405. laser_spotlight_part_template.FormFactor = "Custom"
  2406. laser_spotlight_part_template.Locked = true
  2407. laser_spotlight_part_template.Size = Vector3.new(0.2, 0.2, 0.2)
  2408. laser_spotlight_part_template.TopSurface = "Smooth"
  2409. laser_spotlight_part_template.Transparency = 1
  2410. laser_spotlight_light_template.Angle = 45
  2411. laser_spotlight_light_template.Color = laser_color
  2412. laser_spotlight_light_template.Enabled = true
  2413. laser_spotlight_light_template.Name = "Light"
  2414. laser_spotlight_light_template.Range = 60
  2415. for index = 1, 40 do
  2416. local laser_spotlight_part = laser_spotlight_part_template:Clone()
  2417. laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -30 * (index - 1))
  2418. laser_spotlight_part.Parent = magic_circle_model
  2419. laser_lights[index] = {laser_spotlight_part, laser_spotlight_part.Light}
  2420. end
  2421. end
  2422. local laser_effects
  2423. if special_effects then
  2424. laser_effects = {}
  2425. local laser_effect_1 = laser_part:Clone()
  2426. laser_effect_1.BrickColor = special_effects
  2427. laser_effect_1.Transparency = 0.5
  2428. local laser_effect_2 = laser_effect_1:Clone()
  2429. laser_effects[1], laser_effects[2] = {laser_effect_1, laser_effect_1.Mesh}, {laser_effect_2, laser_effect_2.Mesh}
  2430. laser_effect_1.Parent = magic_circle_model
  2431. laser_effect_2.Parent = magic_circle_model
  2432. end
  2433. GraphicalEffects.laser_data[{0, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part,
  2434.  
  2435. magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay,
  2436.  
  2437. light_effects}] = true
  2438. end
  2439. end
  2440.  
  2441. function GraphicalEffects.SpawnSapientRock(position)
  2442. local part = Instance.new("Part", Workspace)
  2443. local size = 8 + math.random(0, 5)
  2444. part.BottomSurface = "Smooth"
  2445. part.TopSurface = "Smooth"
  2446. part.Material = "Slate"
  2447. part.Locked = true
  2448. part.Shape = "Ball"
  2449. part.FormFactor = "Custom"
  2450. part.Size = Vector3.new(size, size, size)
  2451. part.Position = position
  2452. local bodypos = Instance.new("BodyPosition", part)
  2453. bodypos.maxForce = Vector3.new(0, 0, 0)
  2454. local angry = false
  2455. local damage_ready = true
  2456. local torso_following
  2457. local torso_changed = -1000
  2458. local touched_conn = part.Touched:connect(function(hit)
  2459. local character = hit.Parent
  2460. if character then
  2461. local humanoid
  2462. for _, child in ipairs(character:GetChildren()) do
  2463. if child:IsA("Humanoid") then
  2464. humanoid = child
  2465. break
  2466. end
  2467. end
  2468. if humanoid then
  2469. if angry then
  2470. if damage_ready then
  2471. damage_ready = false
  2472. humanoid:TakeDamage(100)
  2473. wait(1)
  2474. damage_ready = true
  2475. angry = false
  2476. part.BrickColor = BrickColor.new("Medium stone grey")
  2477. end
  2478. else
  2479. local torso = humanoid.Torso
  2480. if torso then
  2481. torso_following = torso
  2482. torso_changed = tick()
  2483. end
  2484. end
  2485. end
  2486. end
  2487. end)
  2488. TaskScheduler.Start(function()
  2489. while part.Parent == Workspace do
  2490. if torso_following then
  2491. bodypos.position = torso_following.Position
  2492. if tick() - torso_changed > 60 or not torso_following.Parent then
  2493. torso_following = nil
  2494. bodypos.maxForce = Vector3.new(0, 0, 0)
  2495. angry = false
  2496. part.BrickColor = BrickColor.new("Medium stone grey")
  2497. else
  2498. local speed = angry and Vector3.new(16, 16, 16) or Vector3.new(6, 0, 6)
  2499. bodypos.maxForce = part:GetMass() * speed
  2500. if part.Position.Y < -250 then
  2501. part.Velocity = Vector3.new()
  2502. part.Position = torso_following.Position + Vector3.new(0, 80, 0)
  2503. part.BrickColor = BrickColor.new("Bright red")
  2504. angry = true
  2505. torso_changed = tick()
  2506. end
  2507. end
  2508. end
  2509. RunService.Stepped:wait()
  2510. end
  2511. touched_conn:disconnect()
  2512. end)
  2513. TaskScheduler.Start(function()
  2514. while part.Parent == Workspace do
  2515. wait(25 + math.random() * 10)
  2516. local next_size = 8 + math.random() * 5
  2517. if math.random(100) == 1 then
  2518. next_size = next_size * (2 + 6 * math.random())
  2519. end
  2520. next_size = math.floor(next_size + 0.5)
  2521. local start_time = tick()
  2522. local mesh = Instance.new("SpecialMesh", part)
  2523. mesh.MeshType = "Sphere"
  2524. repeat
  2525. local elapsed_time = tick() - start_time
  2526. local alpha = math.cos(elapsed_time * math.pi * 0.5)
  2527. local interpolated_size = size * alpha + next_size * (1 - alpha)
  2528. local size_vector = Vector3.new(interpolated_size, interpolated_size, interpolated_size)
  2529. local cframe = part.CFrame
  2530. part.Size = size_vector
  2531. part.CFrame = cframe
  2532. mesh.Scale = size_vector / part.Size
  2533. RunService.Stepped:wait()
  2534. until tick() - start_time >= 1
  2535. mesh:Destroy()
  2536. local cframe = part.CFrame
  2537. part.Size = Vector3.new(next_size, next_size, next_size)
  2538. part.CFrame = cframe
  2539. size = next_size
  2540. end
  2541. end)
  2542. end
  2543.  
  2544. function GraphicalEffects.MainLoop()
  2545. RunService.Stepped:wait()
  2546. for data in pairs(GraphicalEffects.magicCircleData) do
  2547. GraphicalEffects.AnimateMagicCircle(data)
  2548. end
  2549. for data in pairs(GraphicalEffects.laser_data) do
  2550. GraphicalEffects.AnimateLaserOfDeath(data)
  2551. end
  2552. for data in pairs(GraphicalEffects.missileData) do
  2553. GraphicalEffects.AnimateMissile(data)
  2554. end
  2555. end
  2556. TaskScheduler.Start(function()
  2557. while true do
  2558. GraphicalEffects.MainLoop()
  2559. end
  2560. end)
  2561.  
  2562. PlayerControl = {};
  2563.  
  2564. PlayerControl.fly_acceleration = 10
  2565. PlayerControl.fly_basespeed = 250
  2566. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  2567. PlayerControl.featherfallEnabled = true
  2568. PlayerControl.pushable = false
  2569. PlayerControl.rolling = false
  2570. PlayerControl.rollingAngle = 0
  2571. PlayerControl.rollingOffset = 0
  2572. PlayerControl.rollingMaxOffset = 3
  2573. PlayerControl.rollingSpeed = 1 / 50
  2574. PlayerControl.characterEnabled = false
  2575. PlayerControl.characterMode = "normal"
  2576. local character = nil
  2577. local flying, flyingMomentum, flyingTilt = false, Vector3.new(), 0
  2578. local pose, regeneratingHealth, jumpDebounce = "Standing", false, false
  2579. -- TODO: make local variables public
  2580. local model, bodyColors, leftArmMesh, leftLegMesh, rightArmMesh, rightLegMesh, torsoMesh, wildcardHat, wildcardHandle, wildcardMesh, pants, shirt, humanoid,
  2581.  
  2582. head, leftArm, leftLeg, rightArm, rightLeg, torso, rootPart, rootJoint, face, soundFreeFalling, soundGettingUp, soundRunning, leftHip, leftShoulder,
  2583.  
  2584. rightHip, rightShoulder, neck, wildcardWeld, feetPart, feetWeld, feetTouchInterest, bodyGyro, bodyVelocity, headMesh, torsoLight
  2585. local AnimateCharacter
  2586. local UserInterface = game:service'UserInputService'
  2587. local chatBubbles = {}
  2588. local chatCharacterLimit = 240
  2589. function PlayerControl.CreateCharacter()
  2590. local characterMode = PlayerControl.characterMode
  2591. if characterMode == "normal" then
  2592. if not PlayerControl.characterEnabled then
  2593. return
  2594. end
  2595. local appearance = CharacterAppearance.GetDefaultAppearance()
  2596. local active = true
  2597. local torsoCFrame = (torso and torso.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2598. if torsoCFrame.p.Y < -450 then
  2599. torsoCFrame = CFrame.new(0, 10, 0)
  2600. end
  2601. local rootPartCFrame = (rootPart and rootPart.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2602. if rootPartCFrame.p.Y < -450 then
  2603. rootPartCFrame = CFrame.new(0, 10, 0)
  2604. end
  2605. local cameraCFrame = Camera.CoordinateFrame
  2606. local connections = {}
  2607. local feetTouching = {}
  2608. local previousWalkSpeed = 0
  2609. local prevLeftHip, prevLeftShoulder, prevRightHip, prevRightShoulder = leftHip, leftShoulder, rightHip, rightShoulder
  2610. model = Instance.new("Model")
  2611. humanoid = Instance.new("Humanoid", model)
  2612. head = Instance.new("Part", model)
  2613. leftArm = Instance.new("Part", model)
  2614. leftLeg = Instance.new("Part", model)
  2615. rightArm = Instance.new("Part", model)
  2616. rightLeg = Instance.new("Part", model)
  2617. torso = Instance.new("Part", model)
  2618. rootPart = Instance.new("Part", model)
  2619. soundFallingDown = Instance.new("Sound", head)
  2620. soundFreeFalling = Instance.new("Sound", head)
  2621. soundGettingUp = Instance.new("Sound", head)
  2622. soundJumping = Instance.new("Sound", head)
  2623. soundRunning = Instance.new("Sound", head)
  2624. leftHip = Instance.new("Motor", torso)
  2625. leftShoulder = Instance.new("Motor", torso)
  2626. rightHip = Instance.new("Motor", torso)
  2627. rightShoulder = Instance.new("Motor", torso)
  2628. neck = Instance.new("Motor", torso)
  2629. rootJoint = Instance.new("Motor", rootPart)
  2630. feetPart = Instance.new("Part", model)
  2631. feetWeld = Instance.new("Weld", torso)
  2632. bodyGyro = Instance.new("BodyGyro", rootPart)
  2633. bodyVelocity = Instance.new("BodyVelocity", rootPart)
  2634. model.Archivable = false
  2635. model.Name = user_name or Player.Name
  2636. model.PrimaryPart = head
  2637. humanoid.LeftLeg = leftLeg
  2638. humanoid.RightLeg = rightLeg
  2639. humanoid.Torso = rootPart
  2640. head.CFrame = torsoCFrame * CFrame.new(0, 1.5, 0)
  2641. head.FormFactor = "Symmetric"
  2642. head.Locked = true
  2643. head.Name = "Head"
  2644. head.Size = Vector3.new(2, 1, 1)
  2645. head.TopSurface = "Smooth"
  2646. leftArm.CanCollide = false
  2647. leftArm.CFrame = torsoCFrame * CFrame.new(-1.5, 0, 0)
  2648. leftArm.FormFactor = "Symmetric"
  2649. leftArm.Locked = true
  2650. leftArm.Name = "Left Arm"
  2651. leftArm.Size = Vector3.new(1, 2, 1)
  2652. leftLeg.BottomSurface = "Smooth"
  2653. leftLeg.CanCollide = false
  2654. leftLeg.CFrame = torsoCFrame * CFrame.new(-0.5, -2, 0)
  2655. leftLeg.FormFactor = "Symmetric"
  2656. leftLeg.Locked = true
  2657. leftLeg.Name = "Left Leg"
  2658. leftLeg.Size = Vector3.new(1, 2, 1)
  2659. leftLeg.TopSurface = "Smooth"
  2660. rightArm.CanCollide = false
  2661. rightArm.CFrame = torsoCFrame * CFrame.new(1.5, 0, 0)
  2662. rightArm.FormFactor = "Symmetric"
  2663. rightArm.Locked = true
  2664. rightArm.Name = "Right Arm"
  2665. rightArm.Size = Vector3.new(1, 2, 1)
  2666. rightLeg.BottomSurface = "Smooth"
  2667. rightLeg.CanCollide = false
  2668. rightLeg.CFrame = torsoCFrame * CFrame.new(0.5, -2, 0)
  2669. rightLeg.FormFactor = "Symmetric"
  2670. rightLeg.Locked = true
  2671. rightLeg.Name = "Right Leg"
  2672. rightLeg.Size = Vector3.new(1, 2, 1)
  2673. rightLeg.TopSurface = "Smooth"
  2674. torso.CFrame = torsoCFrame
  2675. torso.FormFactor = "Symmetric"
  2676. torso.LeftSurface = "Weld"
  2677. torso.Locked = true
  2678. torso.RightSurface = "Weld"
  2679. torso.Name = "Torso"
  2680. torso.Size = Vector3.new(2, 2, 1)
  2681. rootPart.BottomSurface = "Smooth"
  2682. rootPart.BrickColor = BrickColor.Blue()
  2683. rootPart.CFrame = rootPartCFrame
  2684. rootPart.FormFactor = "Symmetric"
  2685. rootPart.LeftSurface = "Weld"
  2686. rootPart.Locked = true
  2687. rootPart.RightSurface = "Weld"
  2688. rootPart.Name = "HumanoidRootPart"
  2689. rootPart.Size = Vector3.new(2, 2, 1)
  2690. rootPart.TopSurface = "Smooth"
  2691. rootPart.Transparency = 1
  2692. soundFreeFalling.Archivable = false
  2693. soundFreeFalling.SoundId = "rbxasset://sounds/swoosh.wav"
  2694. soundGettingUp.Archivable = false
  2695. soundGettingUp.SoundId = "rbxasset://sounds/hit.wav"
  2696. soundRunning.Archivable = false
  2697. soundRunning.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
  2698. soundRunning.Looped = true
  2699. leftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2700. leftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2701. leftHip.MaxVelocity = 0.1
  2702. leftHip.Name = "Left Hip"
  2703. leftHip.Part0 = torso
  2704. leftHip.Part1 = leftLeg
  2705. leftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2706. leftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2707. leftShoulder.MaxVelocity = 0.15
  2708. leftShoulder.Name = "Left Shoulder"
  2709. leftShoulder.Part0 = torso
  2710. leftShoulder.Part1 = leftArm
  2711. rightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2712. rightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2713. rightHip.MaxVelocity = 0.1
  2714. rightHip.Name = "Right Hip"
  2715. rightHip.Part0 = torso
  2716. rightHip.Part1 = rightLeg
  2717. rightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2718. rightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2719. rightShoulder.MaxVelocity = 0.15
  2720. rightShoulder.Name = "Right Shoulder"
  2721. rightShoulder.Part0 = torso
  2722. rightShoulder.Part1 = rightArm
  2723. if prevLeftHip then
  2724. leftHip.CurrentAngle = prevLeftHip.CurrentAngle
  2725. leftHip.DesiredAngle = prevLeftHip.DesiredAngle
  2726. end
  2727. if prevLeftShoulder then
  2728. leftShoulder.CurrentAngle = prevLeftShoulder.CurrentAngle
  2729. leftShoulder.DesiredAngle = prevLeftShoulder.DesiredAngle
  2730. end
  2731. if prevRightHip then
  2732. rightHip.CurrentAngle = prevRightHip.CurrentAngle
  2733. rightHip.DesiredAngle = prevRightHip.DesiredAngle
  2734. end
  2735. if prevRightShoulder then
  2736. rightShoulder.CurrentAngle = prevRightShoulder.CurrentAngle
  2737. rightShoulder.DesiredAngle = prevRightShoulder.DesiredAngle
  2738. end
  2739. neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2740. neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2741. neck.Name = "Neck"
  2742. neck.Part0 = torso
  2743. neck.Part1 = head
  2744. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2745. rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2746. rootJoint.Name = "RootJoint"
  2747. rootJoint.Part0 = rootPart
  2748. rootJoint.Part1 = torso
  2749. feetPart.BottomSurface = "Smooth"
  2750. feetPart.CanCollide = false
  2751. feetPart.CFrame = torsoCFrame * CFrame.new(0, -3.1, 0)
  2752. feetPart.FormFactor = "Custom"
  2753. feetPart.Locked = true
  2754. feetPart.Name = "Platform"
  2755. feetPart.Size = Vector3.new(1.8, 0.2, 0.8)
  2756. feetPart.TopSurface = "Smooth"
  2757. feetPart.Transparency = 1
  2758. feetWeld.C0 = CFrame.new(0, -3, 0)
  2759. feetWeld.C1 = CFrame.new(0, 0.1, 0)
  2760. feetWeld.Name = "PlatformWeld"
  2761. feetWeld.Part0 = torso
  2762. feetWeld.Part1 = feetPart
  2763. table.insert(connections, feetPart.Touched:connect(function(hit)
  2764. feetTouching[hit] = true
  2765. end))
  2766. table.insert(connections, feetPart.TouchEnded:connect(function(hit)
  2767. feetTouching[hit] = nil
  2768. end))
  2769. feetTouchInterest = feetPart:FindFirstChild("TouchInterest")
  2770. bodyGyro.D = 3250
  2771. bodyGyro.P = 400000
  2772. bodyGyro.maxTorque = Vector3.new(1000000000, 0, 1000000000)
  2773. bodyVelocity.P = 5000
  2774. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  2775. bodyVelocity.velocity = Vector3.new(0, 0, 0)
  2776. torsoLight = Instance.new("PointLight", torso)
  2777. torsoLight.Brightness = 0.4
  2778. torsoLight.Color = Color3.new(1, 1, 1)
  2779. torsoLight.Range = 16
  2780. torsoLight.Shadows = true
  2781. local ff1, ff2, ff3, ff4, ff5, ff6, ff7, ff8, ff9 = Instance.new("ForceField", head), Instance.new("ForceField", leftArm), Instance.new("ForceField", leftLeg), Instance.new("ForceField", rightArm), Instance.new("ForceField", rightLeg), Instance.new("ForceField", torso), Instance.new("ForceField", wildcardHandle), Instance.new("ForceField", feetPart), Instance.new("ForceField", rootPart)
  2782. local forcefields = {[ff1] = head, [ff2] = leftArm, [ff3] = leftLeg, [ff4] = rightArm, [ff5] = rightLeg, [ff6] = torso, [ff7] = wildcardHandle, [ff8] = feetPart, [ff9] = rootPart}
  2783. local objects = {[humanoid] = true, [head] = true, [leftArm] = true, [leftLeg] = true, [rightArm] = true, [rightLeg] = true, [torso] = true, [rootPart] = true, [rootJoint] = true, [soundFreeFalling] = true, [soundGettingUp] = true, [soundRunning] = true, [leftHip] = true, [leftShoulder] = true, [rightHip] = true, [rightShoulder] = true, [neck] = true, [feetPart] = true, [feetWeld] = true, [feetTouchInterest] = true, [bodyGyro] = true, [bodyVelocity] = true, [ff1] = true, [ff2] = true, [ff3] = true, [ff4] = true, [ff5] = true, [ff6] = true, [ff7] = true, [ff8] = true, [ff9] = true}
  2784. local tshirtUrl = appearance.tshirt
  2785. if tshirtUrl then
  2786. local tshirt = Instance.new("Decal", torso)
  2787. tshirt.Name = "roblox"
  2788. tshirt.Texture = tshirtUrl
  2789. objects[tshirt] = true
  2790. end
  2791. for _, template in ipairs(appearance.characterObjects) do
  2792. local object = template:Clone()
  2793. local newObjects = {object}
  2794. for _, object in ipairs(newObjects) do
  2795. objects[object] = true
  2796. for _, child in ipairs(object:GetChildren()) do
  2797. table.insert(newObjects, child)
  2798. end
  2799. end
  2800. if object:IsA("BodyColors") then
  2801. head.BrickColor = object.HeadColor
  2802. leftArm.BrickColor = object.LeftArmColor
  2803. leftLeg.BrickColor = object.LeftLegColor
  2804. rightArm.BrickColor = object.RightArmColor
  2805. rightLeg.BrickColor = object.RightLegColor
  2806. torso.BrickColor = object.TorsoColor
  2807. elseif object:IsA("Hat") then
  2808. local handle = object:FindFirstChild("Handle")
  2809. if handle and handle:IsA("BasePart") then
  2810. local weld = Instance.new("Weld", head)
  2811. weld.C0 = CFrame.new(0, 0.5, 0)
  2812. local attachmentPos = object.AttachmentPos
  2813. local attachmentRight = object.AttachmentRight
  2814. local attachmentUp = object.AttachmentUp
  2815. local attachmentForward = object.AttachmentForward
  2816. weld.C1 = CFrame.new(attachmentPos.X, attachmentPos.Y, attachmentPos.Z,
  2817. attachmentRight.X, attachmentUp.X, -attachmentForward.X,
  2818. attachmentRight.Y, attachmentUp.Y, -attachmentForward.Y,
  2819. attachmentRight.Z, attachmentUp.Z, -attachmentForward.Z)
  2820. weld.Name = "HeadWeld"
  2821. weld.Part0 = head
  2822. weld.Part1 = handle
  2823. handle.Parent = model
  2824. local antiGravity = Instance.new("BodyForce", handle)
  2825. antiGravity.force = Vector3.new(0, handle:GetMass() * 196.2, 0)
  2826. objects[object] = false
  2827. object.Parent = nil
  2828. objects[weld] = true
  2829. end
  2830. end
  2831. object.Parent = model
  2832. end
  2833. local facePresent = false
  2834. local headMeshPresent = false
  2835. for _, template in ipairs(appearance.headObjects) do
  2836. local object = template:Clone()
  2837. local newObjects = {object}
  2838. for _, object in ipairs(newObjects) do
  2839. objects[object] = true
  2840. for _, child in ipairs(object:GetChildren()) do
  2841. table.insert(newObjects, child)
  2842. end
  2843. end
  2844. if object:IsA("DataModelMesh") then
  2845. headMeshPresent = true
  2846. elseif object:IsA("Decal") then
  2847. facePresent = true
  2848. end
  2849. object.Parent = head
  2850. end
  2851. if not facePresent then
  2852. local face = Instance.new("Decal", head)
  2853. face.Texture = "rbxasset://textures/face.png"
  2854. objects[face] = true
  2855. end
  2856. if not headMeshPresent then
  2857. local headMesh = Instance.new("SpecialMesh", head)
  2858. headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  2859. objects[headMesh] = true
  2860. end
  2861. table.insert(connections, model.DescendantAdded:connect(function(object)
  2862. local success, is_localscript = pcall(Game.IsA, object, "LocalScript")
  2863. if success and is_localscript then
  2864. pcall(Utility.SetProperty, object, "Disabled", true)
  2865. local changed_connection = pcall(object.Changed.connect, object.Changed, function(property)
  2866. if property == "Disabled" and not object.Disabled then
  2867. pcall(Utility.SetProperty, object, "Disabled", true)
  2868. object:Destroy()
  2869. end
  2870. end)
  2871. end
  2872. if not objects[object] then
  2873. object:Destroy()
  2874. end
  2875. end))
  2876. model.Parent = Workspace
  2877. Player.Character = model
  2878. Camera.CameraSubject = humanoid
  2879. Camera.CameraType = "Track"
  2880. Camera.CoordinateFrame = cameraCFrame
  2881. local IsStanding
  2882. local RegenerateHealth
  2883. local ResetCharacter
  2884. function IsStanding()
  2885. return not not next(feetTouching)
  2886. end
  2887. function RegenerateHealth()
  2888. if humanoid.Health < 1 then
  2889. humanoid.Health = 100
  2890. elseif not regeneratingHealth then
  2891. regeneratingHealth = true
  2892. local elapsedTime = wait(1)
  2893. regeneratingHealth = false
  2894. if humanoid.Health < 100 then
  2895. humanoid.Health = math.min(humanoid.Health + elapsedTime, 100)
  2896. end
  2897. end
  2898. end
  2899. function ResetCharacter()
  2900. for index, connection in ipairs(connections) do
  2901. connection:disconnect()
  2902. end
  2903. active = false
  2904. end
  2905. table.insert(connections, model.AncestryChanged:connect(ResetCharacter))
  2906. table.insert(connections, model.DescendantRemoving:connect(function(object)
  2907. local parent = forcefields[object]
  2908. if parent then
  2909. forcefields[object] = nil
  2910. local new_forcefield = Instance.new("ForceField")
  2911. forcefields[new_forcefield] = parent
  2912. objects[new_forcefield] = true
  2913. new_forcefield.Parent = parent
  2914. elseif objects[object] then
  2915. ResetCharacter()
  2916. end
  2917. end))
  2918. table.insert(connections, humanoid.HealthChanged:connect(RegenerateHealth))
  2919. table.insert(connections, humanoid.Climbing:connect(function() pose = "Climbing" end))
  2920. table.insert(connections, humanoid.FallingDown:connect(function(state) pose = "FallingDown" end))
  2921. table.insert(connections, humanoid.FreeFalling:connect(function(state) pose = "FreeFall" if state then soundFreeFalling:Play() else
  2922.  
  2923. soundFreeFalling:Pause() end end))
  2924. table.insert(connections, humanoid.GettingUp:connect(function(state) pose = "GettingUp" if state then soundGettingUp:Play() else
  2925.  
  2926. soundGettingUp:Pause() end end))
  2927. table.insert(connections, humanoid.PlatformStanding:connect(function() pose = "PlatformStanding" end))
  2928. table.insert(connections, humanoid.Seated:connect(function() pose = "Seated" end))
  2929. table.insert(connections, humanoid.Swimming:connect(function(speed) if speed > 0 then pose = "Swimming" else pose = "Standing" end end))
  2930. local previousRootPartCFrame = rootPart.CFrame
  2931. TaskScheduler.Start(function()
  2932. while active do
  2933. local totalTime = TaskScheduler.GetCurrentTime()
  2934. local stepTime = 1 / 60
  2935. if not PlayerControl.characterEnabled then
  2936. ResetCharacter()
  2937. break
  2938. end
  2939. torsoLight.Brightness = 0.5 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
  2940. local featherfallEnabled = PlayerControl.IsFeatherfallEnabled()
  2941. local rootPartCFrame = rootPart.CFrame
  2942. if not jumpDebounce and UserInterface:IsKeyDown(Enum.KeyCode.Space) then
  2943. if humanoid.Sit then
  2944. humanoid.Sit = false
  2945. end
  2946. if IsStanding() then
  2947. jumpDebounce = true
  2948. pose = "Jumping"
  2949. rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 50, rootPart.Velocity.Z)
  2950. torso.Velocity = Vector3.new(torso.Velocity.X, 50, torso.Velocity.Z)
  2951. TaskScheduler.Schedule(1, function()
  2952. if pose == "Jumping" then
  2953. pose = "FreeFall"
  2954. end
  2955. jumpDebounce = false
  2956. humanoid.Jump = false
  2957. end)
  2958. end
  2959. end
  2960. local cameraCFrame = Camera.CoordinateFrame
  2961. local cameraDirection = cameraCFrame.lookVector
  2962. if flying then
  2963. if PlayerControl.rolling then
  2964. local rootPartCFrame = rootPart.CFrame
  2965. local speed = (rootPartCFrame - rootPartCFrame.p):pointToObjectSpace(rootPart.Velocity).Y
  2966. local decay = 0.5 ^ stepTime
  2967. if math.abs(speed) <= 50 then
  2968. PlayerControl.rollingAngle = (((PlayerControl.rollingAngle + 0.5) % 1 - 0.5) * decay) % 1
  2969. PlayerControl.rollingOffset = PlayerControl.rollingOffset * decay
  2970. else
  2971. PlayerControl.rollingAngle = (PlayerControl.rollingAngle + stepTime * speed * PlayerControl.rollingSpeed) % 1
  2972. PlayerControl.rollingOffset = (PlayerControl.rollingOffset + PlayerControl.rollingMaxOffset * (1 / decay - 1)) * decay
  2973. end
  2974. rootJoint.C0 = (CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) * CFrame.Angles(PlayerControl.rollingAngle * 2 * math.pi, 0, 0)) * CFrame.new(0, -PlayerControl.rollingOffset, 0)
  2975. else
  2976. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2977. PlayerControl.rollingAngle = 0
  2978. PlayerControl.rollingOffset = 0
  2979. end
  2980. rightShoulder.MaxVelocity = 0.5
  2981. leftShoulder.MaxVelocity = 0.5
  2982. rightShoulder.DesiredAngle = 0
  2983. leftShoulder.DesiredAngle = 0
  2984. rightHip.DesiredAngle = 0
  2985. leftHip.DesiredAngle = 0
  2986. bodyGyro.D = 500
  2987. bodyGyro.P = 1e6
  2988. bodyGyro.maxTorque = Vector3.new(1e6, 1e6, 1e6)
  2989. bodyVelocity.P = 1250
  2990. bodyVelocity.maxForce = Vector3.new(1e6, 1e6, 1e6)
  2991. local movementRight = 0
  2992. local movementForward = 0
  2993. local movementUp = 0
  2994. if UserInterface:IsKeyDown(Enum.KeyCode.A) and not UserInterface:IsKeyDown(Enum.KeyCode.D) then
  2995. movementRight = -1
  2996. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  2997. movementRight = 1
  2998. end
  2999. if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  3000. movementUp = 0.2
  3001. if not UserInterface:IsKeyDown(Enum.KeyCode.S) then
  3002. movementForward = -1
  3003. end
  3004. elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  3005. movementForward = 1
  3006. end
  3007. local movement = PlayerControl.fly_acceleration * cameraCFrame:vectorToWorldSpace(Vector3.new(movementRight, movementUp, movementForward))
  3008. local previousMomentum = flyingMomentum
  3009. local previousTilt = flyingTilt
  3010. flyingMomentum = movement + flyingMomentum * (1 - PlayerControl.fly_acceleration / PlayerControl.fly_speed)
  3011. flyingTilt = ((flyingMomentum * Vector3.new(1, 0, 1)).unit:Cross((previousMomentum * Vector3.new(1, 0, 1)).unit)).Y
  3012. if flyingTilt ~= flyingTilt or flyingTilt == math.huge then
  3013. flyingTilt = 0
  3014. end
  3015. local absoluteTilt = math.abs(flyingTilt)
  3016. if absoluteTilt > 0.06 or absoluteTilt < 0.0001 then
  3017. if math.abs(previousTilt) > 0.0001 then
  3018. flyingTilt = previousTilt * 0.9
  3019. else
  3020. flyingTilt = 0
  3021. end
  3022. else
  3023. flyingTilt = previousTilt * 0.77 + flyingTilt * 0.25
  3024. end
  3025. previousTilt = flyingTilt
  3026. if flyingMomentum.magnitude < 0.1 then
  3027. flyingMomentum = Vector3.new(0, 0, 0)
  3028. -- bodyGyro.cframe = cameraCFrame
  3029. else
  3030. local momentumOrientation = CFrame.new(Vector3.new(0, 0, 0), flyingMomentum)
  3031. local tiltOrientation = CFrame.Angles(0, 0, -20 * flyingTilt)
  3032. bodyGyro.cframe = momentumOrientation * tiltOrientation * CFrame.Angles(-0.5 * math.pi * math.min(flyingMomentum.magnitude / PlayerControl.fly_speed, 1), 0, 0)
  3033. end
  3034. bodyVelocity.velocity = flyingMomentum + Vector3.new(0, 0.15695775618683547, 0)
  3035. rootPart.Velocity = flyingMomentum
  3036. previousMomentum = flyingMomentum
  3037. else
  3038. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  3039. PlayerControl.rollingAngle = 0
  3040. PlayerControl.rollingOffset = 0
  3041. bodyGyro.D = 3250
  3042. bodyGyro.P = 400000
  3043. bodyVelocity.P = 5000
  3044. local cameraDirection = cameraCFrame.lookVector
  3045. local walkDirection = Vector3.new(0, 0, 0)
  3046. local walkSpeed = 16
  3047. if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  3048. if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3049. walkDirection = Vector3.new(cameraDirection.X + cameraDirection.Z, 0, cameraDirection.Z - cameraDirection.X).unit
  3050. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3051. walkDirection = Vector3.new(cameraDirection.X - cameraDirection.Z, 0, cameraDirection.Z + cameraDirection.X).unit
  3052. else
  3053. walkDirection = Vector3.new(cameraDirection.X, 0, cameraDirection.Z).unit
  3054. end
  3055. elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  3056. if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3057. walkDirection = Vector3.new(-cameraDirection.X + cameraDirection.Z, 0, -cameraDirection.Z - cameraDirection.X).unit
  3058. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3059. walkDirection = Vector3.new(-cameraDirection.X - cameraDirection.Z, 0, -cameraDirection.Z + cameraDirection.X).unit
  3060. else
  3061. walkDirection = Vector3.new(-cameraDirection.X, 0, -cameraDirection.Z).unit
  3062. end
  3063. elseif UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3064. walkDirection = Vector3.new(cameraDirection.Z, 0, -cameraDirection.X).unit
  3065. elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3066. walkDirection = Vector3.new(-cameraDirection.Z, 0, cameraDirection.X).unit
  3067. else
  3068. walkSpeed = 0
  3069. end
  3070. if walkSpeed ~= previousWalkSpeed then
  3071. if walkSpeed > 0 then
  3072. soundRunning:Play()
  3073. else
  3074. soundRunning:Pause()
  3075. end
  3076. end
  3077. if walkSpeed > 0 then
  3078. if pose ~= "Jumping" then
  3079. if IsStanding() then
  3080. pose = "Running"
  3081. else
  3082. pose = "FreeFall"
  3083. end
  3084. end
  3085. bodyGyro.cframe = CFrame.new(Vector3.new(), walkDirection)
  3086. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000)
  3087. bodyVelocity.maxForce = Vector3.new(1000000, maxForceY, 1000000)
  3088. else
  3089. if pose ~= "Jumping" then
  3090. if IsStanding() then
  3091. pose = "Standing"
  3092. else
  3093. pose = "FreeFall"
  3094. end
  3095. end
  3096. -- TODO: find and fix bug that causes torso to rotate back to some angle
  3097. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000) -- Vector3.new(1000000000, 0, 1000000000)
  3098. if PlayerControl.pushable then
  3099. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  3100. else
  3101. bodyVelocity.maxForce = Vector3.new(1000000, 0, 1000000)
  3102. end
  3103. end
  3104. if featherfallEnabled then
  3105. local velocity = rootPart.Velocity
  3106. if velocity.Y > 50 then
  3107. rootPart.Velocity = Vector3.new(velocity.X, 50, velocity.Z)
  3108. elseif velocity.Y < -50 then
  3109. rootPart.Velocity = Vector3.new(velocity.X, -50, velocity.Z)
  3110. end
  3111. local distanceVector = rootPartCFrame.p - previousRootPartCFrame.p
  3112. local offsetX, offsetY, offsetZ = distanceVector.X, distanceVector.Y, distanceVector.Z
  3113. local MAX_MOVEMENT = 50 * 0.03333333507180214
  3114. if offsetX > MAX_MOVEMENT then
  3115. offsetX = MAX_MOVEMENT
  3116. elseif offsetX < -MAX_MOVEMENT then
  3117. offsetX = -MAX_MOVEMENT
  3118. end
  3119. if offsetY > MAX_MOVEMENT then
  3120. offsetY = MAX_MOVEMENT
  3121. elseif offsetY < -MAX_MOVEMENT then
  3122. offsetY = -MAX_MOVEMENT
  3123. end
  3124. if offsetZ > MAX_MOVEMENT then
  3125. offsetZ = MAX_MOVEMENT
  3126. elseif offsetZ < -MAX_MOVEMENT then
  3127. offsetZ = -MAX_MOVEMENT
  3128. end
  3129. local offset = Vector3.new(offsetX, offsetY, offsetZ)
  3130. if offset ~= distanceVector then
  3131. rootPartCFrame = previousRootPartCFrame + offset
  3132. --rootPart.CFrame = rootPartCFrame
  3133. end
  3134. end
  3135. local walkingVelocity = walkDirection * walkSpeed
  3136. bodyVelocity.velocity = walkingVelocity
  3137. if not jumpDebounce and math.abs(rootPart.Velocity.Y) <= 0.1 then
  3138. rootPart.Velocity = Vector3.new(walkingVelocity.X, rootPart.Velocity.Y, walkingVelocity.Z)
  3139. end
  3140. previousWalkSpeed = walkSpeed
  3141. if pose == "Jumping" or jumpDebounce then
  3142. rightShoulder.MaxVelocity = 0.5
  3143. leftShoulder.MaxVelocity = 0.5
  3144. rightShoulder.DesiredAngle = 3.14
  3145. leftShoulder.DesiredAngle = -3.14
  3146. rightHip.DesiredAngle = 0
  3147. leftHip.DesiredAngle = 0
  3148. elseif pose == "FreeFall" then
  3149. rightShoulder.MaxVelocity = 0.5
  3150. leftShoulder.MaxVelocity = 0.5
  3151. rightShoulder.DesiredAngle = 3.14
  3152. leftShoulder.DesiredAngle = -3.14
  3153. rightHip.DesiredAngle = 0
  3154. leftHip.DesiredAngle = 0
  3155. elseif pose == "Seated" then
  3156. rightShoulder.MaxVelocity = 0.15
  3157. leftShoulder.MaxVelocity = 0.15
  3158. rightShoulder.DesiredAngle = 3.14 / 2
  3159. leftShoulder.DesiredAngle = -3.14 / 2
  3160. rightHip.DesiredAngle = 3.14 / 2
  3161. leftHip.DesiredAngle = -3.14 / 2
  3162. else
  3163. local climbFudge = 0
  3164. local amplitude
  3165. local frequency
  3166. if pose == "Running" then
  3167. rightShoulder.MaxVelocity = 0.15
  3168. leftShoulder.MaxVelocity = 0.15
  3169. amplitude = 1
  3170. frequency = 9
  3171. elseif (pose == "Climbing") then
  3172. rightShoulder.MaxVelocity = 0.5
  3173. leftShoulder.MaxVelocity = 0.5
  3174. amplitude = 1
  3175. frequency = 9
  3176. climbFudge = 3.14
  3177. else
  3178. amplitude = 0.1
  3179. frequency = 1
  3180. end
  3181. local desiredAngle = amplitude * math.sin(totalTime * frequency)
  3182. rightShoulder.DesiredAngle = desiredAngle + climbFudge
  3183. leftShoulder.DesiredAngle = desiredAngle - climbFudge
  3184. rightHip.DesiredAngle = -desiredAngle
  3185. leftHip.DesiredAngle = -desiredAngle
  3186. end
  3187. end
  3188. previousRootPartCFrame = rootPartCFrame
  3189. RunService.RenderStepped:wait()
  3190. end
  3191. if model.Parent ~= nil then
  3192. model.Parent = nil
  3193. end
  3194. PlayerControl.CreateCharacter()
  3195. end)
  3196. humanoid.Health = 100
  3197. character = model
  3198. chatAdornee = head
  3199. elseif characterMode == "pyramid" then
  3200. if PlayerControl.characterEnabled then
  3201. Camera.CameraType = "Fixed"
  3202. PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
  3203. PyramidCharacter.camera_position = Camera.Focus.p
  3204. PyramidCharacter.Teleport(Camera.Focus.p)
  3205. PyramidCharacter.visible = true
  3206. Player.Character = nil
  3207. else
  3208. PyramidCharacter.visible = false
  3209. end
  3210. end
  3211. end
  3212. function PlayerControl.GetCharacter()
  3213. return character
  3214. end
  3215. function PlayerControl.GetHead()
  3216. local characterMode = PlayerControl.characterMode
  3217. if characterMode == "normal" then
  3218. return head
  3219. elseif characterMode == "pyramid" then
  3220. return PyramidCharacter.core
  3221. end
  3222. end
  3223. function PlayerControl.GetHumanoid()
  3224. return humanoid
  3225. end
  3226. function PlayerControl.GetRootPart()
  3227. return rootPart
  3228. end
  3229. function PlayerControl.GetTorso()
  3230. return torso
  3231. end
  3232. function PlayerControl.IsEnabled()
  3233. return PlayerControl.characterEnabled
  3234. end
  3235. function PlayerControl.IsFeatherfallEnabled()
  3236. return PlayerControl.featherfallEnabled
  3237. end
  3238. function PlayerControl.IsPushable()
  3239. return PlayerControl.pushable
  3240. end
  3241. function PlayerControl.IsRolling()
  3242. return PlayerControl.rolling
  3243. end
  3244. function PlayerControl.ResetCharacter()
  3245. if character and character.Parent then
  3246. character.Parent = nil
  3247. end
  3248. PyramidCharacter.visible = false
  3249. end
  3250. function PlayerControl.SetEnabled(state, no_animation)
  3251. state = not not state
  3252. if state ~= PlayerControl.characterEnabled then
  3253. PlayerControl.characterEnabled = state
  3254. local characterMode = PlayerControl.characterMode
  3255. if characterMode == "normal" then
  3256. local torso = PlayerControl.GetRootPart()
  3257. local rootPart = PlayerControl.GetRootPart()
  3258. if rootPart then
  3259. if PlayerControl.characterEnabled then
  3260. local torso_cframe = Camera.Focus:toWorldSpace(PlayerControl.hide_torso_object_cframe)
  3261. PlayerControl.torso_cframe = torso_cframe
  3262. torso.CFrame = torso_cframe
  3263. rootPart.CFrame = torso_cframe
  3264. else
  3265. PlayerControl.hide_torso_object_cframe = Camera.Focus:toObjectSpace(rootPart.CFrame)
  3266. end
  3267. else
  3268. PlayerControl.torso_cframe = Camera.Focus
  3269. end
  3270. if PlayerControl.characterEnabled then
  3271. PlayerControl.CreateCharacter()
  3272. RunService.Stepped:wait()
  3273. coroutine.yield()
  3274. if not no_animation then
  3275. GraphicalEffects.CrystalRing({base_part = PlayerControl.GetTorso(), crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3276. end
  3277. else
  3278. Player.Character = nil
  3279. Camera.CameraType = "Fixed"
  3280. if not no_animation then
  3281. GraphicalEffects.CrystalRing({position = PlayerControl.GetTorso().Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3282. end
  3283. end
  3284. else
  3285. if state then
  3286. PlayerControl.CreateCharacter()
  3287. RunService.Stepped:wait()
  3288. coroutine.yield()
  3289. if not no_animation then
  3290. GraphicalEffects.CrystalRing({base_part = PyramidCharacter.core, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3291. end
  3292. else
  3293. PyramidCharacter.visible = false
  3294. if not no_animation then
  3295. GraphicalEffects.CrystalRing({position = PyramidCharacter.core.Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3296. end
  3297. end
  3298. end
  3299. end
  3300. end
  3301. function PlayerControl.SetFeatherfallEnabled(state)
  3302. state = not not state
  3303. if state ~= PlayerControl.featherfallEnabled then
  3304. PlayerControl.featherfallEnabled = state
  3305. if state then
  3306. Logger.print("Info", "Featherfall enabled in PlayerControl")
  3307. else
  3308. Logger.print("Info", "Featherfall disabled in PlayerControl")
  3309. end
  3310. end
  3311. end
  3312. function PlayerControl.SetPushable(state)
  3313. state = not not state
  3314. if state ~= PlayerControl.pushable then
  3315. PlayerControl.pushable = state
  3316. if state then
  3317. Logger.print("Info", "Pushing enabled in PlayerControl")
  3318. else
  3319. Logger.print("Info", "Pushing disabled in PlayerControl")
  3320. end
  3321. end
  3322. end
  3323. function PlayerControl.SetRolling(state)
  3324. state = not not state
  3325. if state ~= PlayerControl.rolling then
  3326. PlayerControl.rolling = state
  3327. if state then
  3328. Logger.print("Info", "Rolling fly mode enabled in PlayerControl")
  3329. else
  3330. Logger.print("Info", "Rolling fly mode disabled in PlayerControl")
  3331. end
  3332. end
  3333. end
  3334. function PlayerControl.StartFlying()
  3335. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  3336. if torso then
  3337. flyingMomentum = torso.Velocity + torso.CFrame.lookVector * 3 + Vector3.new(0, 10, 0)
  3338. else
  3339. flyingMomentum = Vector3.new()
  3340. end
  3341. flyingTilt = 0
  3342. flying = true
  3343. end
  3344. function PlayerControl.StopFlying()
  3345. if bodyGyro.cframe then
  3346. local lookVector = bodyGyro.cframe.lookVector
  3347. if lookVector.X ~= 0 or lookVector.Z ~= 0 then
  3348. bodyGyro.cframe = CFrame.new(Vector3.new(), Vector3.new(lookVector.X, 0, lookVector.Z))
  3349. end
  3350. end
  3351. flying = false
  3352. end
  3353. local previousTime = 0
  3354.  
  3355. ControllerCommands = {};
  3356.  
  3357. ControllerCommands = {};
  3358.  
  3359. ControllerCommands.BALEFIRE_SPEED = 40
  3360. function ControllerCommands.BalefireAtMouse()
  3361. local head = chatAdornee
  3362. if head then
  3363. local target = Mouse.Hit.p
  3364. local origin = head.Position
  3365. local direction = (target - origin).unit
  3366. local explosionCount = 0
  3367. local animation_frame = 0
  3368. local magic_circle_position = origin + direction * 4
  3369. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  3370. local magic_circle_part = Instance.new("Part")
  3371. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  3372. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  3373. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  3374. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  3375. magic_circle_part.Anchored = true
  3376. magic_circle_part.Archivable = false
  3377. magic_circle_part.BottomSurface = "Smooth"
  3378. magic_circle_part.CanCollide = false
  3379. magic_circle_part.CFrame = magic_circle_cframe
  3380. magic_circle_part.FormFactor = "Custom"
  3381. magic_circle_part.Locked = true
  3382. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  3383. magic_circle_part.TopSurface = "Smooth"
  3384. magic_circle_part.Transparency = 1
  3385. magic_circle_mesh.Scale = Vector3.new(60, 60, 0)
  3386. magic_circle_light.Color = Color3.new(1, 0.5, 1)
  3387. magic_circle_light.Range = 16
  3388. magic_circle_light.Shadows = true
  3389. magic_circle_decal_back.Face = "Back"
  3390. magic_circle_decal_back.Texture = "rbxassetid://122610943"
  3391. magic_circle_decal_front.Face = "Front"
  3392. magic_circle_decal_front.Texture = "rbxassetid://122610943"
  3393. local function NextExplosion()
  3394. explosionCount = explosionCount + 1
  3395. Instance.new("Explosion", Workspace).Position = origin + direction * (explosionCount * 8 + 4)
  3396. end
  3397. local function AnimateMagicCircle()
  3398. animation_frame = animation_frame + 1
  3399. local transparency = (animation_frame / 40) ^ 3
  3400. if animation_frame == 40 then
  3401. pcall(Game.Destroy, magic_circle_part)
  3402. else
  3403. if magic_circle_part.Parent ~= Workspace then
  3404. pcall(Utility.SetProperty, magic_circle_part, "Parent", Workspace)
  3405. end
  3406. head = PlayerControl.GetHead()
  3407. if head then
  3408. magic_circle_position = head.Position + direction * 4
  3409. end
  3410. magic_circle_part.CFrame = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0,
  3411.  
  3412. math.tau * animation_frame / 40 * 1.5)
  3413. magic_circle_light.Brightness = 1 - transparency
  3414. magic_circle_decal_back.Transparency = transparency
  3415. magic_circle_decal_front.Transparency = transparency
  3416. end
  3417. end
  3418. magic_circle_part.Parent = Workspace
  3419. for i = 1, 40 do
  3420. Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  3421. Delay((i - 1) / 30, AnimateMagicCircle)
  3422. end
  3423. for i = 1, 20 do
  3424. Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  3425. end
  3426. end
  3427. end
  3428. function ControllerCommands.ControlRandomDummy()
  3429. local dummies = {}
  3430. local numDummies = 0
  3431. for _, character in ipairs(Workspace:GetChildren()) do
  3432. local name = tostring(character)
  3433. if name == "???" or name == "Dummy" then
  3434. local head, humanoid
  3435. for _, child in ipairs(character:GetChildren()) do
  3436. local className = child.ClassName
  3437. if className == "Part" and tostring(child) == "Head" then
  3438. head = child
  3439. if humanoid then
  3440. break
  3441. end
  3442. elseif className == "Humanoid" then
  3443. if child.Health > 0 then
  3444. humanoid = child
  3445. if head then
  3446. break
  3447. end
  3448. else
  3449. break
  3450. end
  3451. end
  3452. end
  3453. if head and humanoid then
  3454. numDummies = numDummies + 1
  3455. dummies[numDummies] = {character, head, humanoid}
  3456. end
  3457. end
  3458. end
  3459. if numDummies > 0 then
  3460. local dummy = dummies[math.random(numDummies)]
  3461. Player.Character = dummy[1]
  3462. chatAdornee = dummy[2]
  3463. Camera.CameraSubject = dummy[3]
  3464. Camera.CameraType = "Track"
  3465. end
  3466. end
  3467. function ControllerCommands.Decalify(textures, exclusion)
  3468. local objects = Workspace:GetChildren()
  3469. for _, object in ipairs(objects) do
  3470. if not exclusion[object] then
  3471. for _, child in ipairs(object:GetChildren()) do
  3472. objects[#objects + 1] = child
  3473. end
  3474. if object:IsA("BasePart") then
  3475. local texture = textures[math.random(#textures)]
  3476. local face_left = Instance.new("Decal", object)
  3477. face_left.Face = Enum.NormalId.Left
  3478. face_left.Texture = texture
  3479. local face_right = Instance.new("Decal", object)
  3480. face_right.Face = Enum.NormalId.Right
  3481. face_right.Texture = texture
  3482. local face_bottom = Instance.new("Decal", object)
  3483. face_bottom.Face = Enum.NormalId.Bottom
  3484. face_bottom.Texture = texture
  3485. local face_top = Instance.new("Decal", object)
  3486. face_top.Face = Enum.NormalId.Top
  3487. face_top.Texture = texture
  3488. local face_front = Instance.new("Decal", object)
  3489. face_front.Face = Enum.NormalId.Front
  3490. face_front.Texture = texture
  3491. local face_back = Instance.new("Decal", object)
  3492. face_back.Face = Enum.NormalId.Back
  3493. face_back.Texture = texture
  3494. end
  3495. end
  3496. end
  3497. end
  3498.  
  3499. function ControllerCommands.ExplodeAtMouse()
  3500. local explosion = Instance.new("Explosion")
  3501. explosion.Position = Mouse.Hit.p
  3502. explosion.Parent = Workspace
  3503. end
  3504. function ControllerCommands.LaserAtMouse()
  3505. GraphicalEffects.ShootLaserOfDeath(Mouse.Hit.p)
  3506. end
  3507. function ControllerCommands.BigLaser(target)
  3508. GraphicalEffects.ShootLaserOfDeath(target, {brickcolor = BrickColor.new("New Yeller"), duration = 80, fragmentation_size = 6,laser_scale = 30, light_color = Color3.new(1, 0.5, 0), magic_circle_image = "rbxassetid://126561317", magic_circle_scale = 1.5, sound_volume = 1,special_effects = BrickColor.new("Deep orange"), stay = 2})
  3509. end
  3510. function ControllerCommands.BigLaserAtMouse()
  3511. ControllerCommands.BigLaser(Mouse.Hit.p)
  3512. end
  3513. function ControllerCommands.ShootMissile(targetPart, pointOnPart, direction)
  3514. GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction)
  3515. end
  3516. function ControllerCommands.ShootMissileAtMouse(amount, spread, delayTime)
  3517. local exclusionList = {}
  3518. local playerHead = PlayerControl.GetHead()
  3519. local playerTorso = PlayerControl.GetTorso()
  3520. if playerHead and playerTorso then
  3521. exclusionList[playerTorso] = true
  3522. local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  3523. local targetPart, pointOnPart
  3524. if humanoid and torso then
  3525. targetPart, pointOnPart = torso, Vector3.new()
  3526. else
  3527. local target = Mouse.Target
  3528. if target then
  3529. targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  3530. else
  3531. return
  3532. end
  3533. end
  3534. if targetPart then
  3535. local direction = (Mouse.Hit.p - playerHead.Position).unit
  3536. delayTime = delayTime or 0
  3537. for index = 1, amount do
  3538. local angles = math.tau * (index - 0.5) * spread / amount * Vector3.new(math.random() - 0.5, math.random() - 0.5,math.random() - 0.5).unit
  3539. TaskScheduler.Schedule(delayTime * (index - 1), ControllerCommands.ShootMissile, targetPart, pointOnPart, CFrame.Angles(angles.X, angles.Y, angles.Z) * direction)
  3540. end
  3541. end
  3542. end
  3543. end
  3544. function ControllerCommands.ShootMissileAroundMouse(amount, offset, delayTime)
  3545. local exclusionList = {}
  3546. local playerHead = PlayerControl.GetHead()
  3547. local playerTorso = PlayerControl.GetTorso()
  3548. if playerHead and playerTorso then
  3549. exclusionList[playerTorso] = true
  3550. local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  3551. local targetPart, pointOnPart
  3552. if humanoid and torso then
  3553. targetPart, pointOnPart = torso, Vector3.new()
  3554. else
  3555. local target = Mouse.Target
  3556. if target then
  3557. targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  3558. else
  3559. return
  3560. end
  3561. end
  3562. if targetPart then
  3563. delayTime = delayTime or 0
  3564. local index = 1
  3565. local targetPoint = targetPart.CFrame * pointOnPart
  3566. local rotation_offset_angles = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, 0).unit
  3567. local rotation_offset = CFrame.Angles(rotation_offset_angles.x, rotation_offset_angles.y, 0)
  3568. local angle_x = 0
  3569. local angle_x_step = math.tau / math.phi
  3570. for i = 1, 8 * amount do
  3571. angle_x = angle_x + angle_x_step
  3572. local direction = rotation_offset * (CFrame.Angles(0, math.tau * index / amount, 0) * CFrame.Angles(angle_x, 0,0).lookVector)
  3573. local blocked = Workspace:FindPartOnRay(Ray.new(targetPoint, direction * offset), targetPart.Parent)
  3574. if not blocked then
  3575. local p0, p1, p2, p3 = targetPart, pointOnPart, direction, offset; GraphicalEffects.ShootMissile(p0, p1, p2, function() return p0 end, p3, true)
  3576. index = index + 1
  3577. if index > amount then
  3578. break
  3579. end
  3580. end
  3581. end
  3582. end
  3583. end
  3584. end
  3585.  
  3586. function ControllerCommands.HugeExplosionOfDoom(position)
  3587. local connections = {}
  3588. local parts = {}
  3589. local cframe = CFrame.new(position)
  3590. local function ExplosionHit(part)
  3591. if part:GetMass() < 10000 and part.Parent ~= Camera then
  3592. parts[part] = true
  3593. part.Anchored = true
  3594. part:BreakJoints()
  3595. part.BrickColor = BrickColor.new("Instituational white")
  3596. end
  3597. end
  3598. for i = 1, 4 do
  3599. local quantity = 0.5 * i * (1 + i)
  3600. local fraction = math.tau / quantity
  3601. for x = 1, quantity do
  3602. for y = 1, quantity do
  3603. local explosion = Instance.new("Explosion")
  3604. connections[#connections + 1] = explosion.Hit:connect(ExplosionHit)
  3605. explosion.BlastRadius = 5
  3606. explosion.Position = cframe * (CFrame.Angles(fraction * x, fraction * y, 0) * Vector3.new((i - 1) * 6, 0, 0))
  3607. explosion.Parent = Workspace
  3608. end
  3609. end
  3610. wait(0.075)
  3611. end
  3612. for part in pairs(parts) do
  3613. for _, child in ipairs(part:GetChildren()) do
  3614. if child:IsA("BodyMover") then
  3615. child:Destroy()
  3616. end
  3617. end
  3618. local mass = part:GetMass()
  3619. local velocity = CFrame.Angles(math.tau * math.random(), math.tau * math.random(), 0) * Vector3.new(25, 0, 0)
  3620. local bodythrust = Instance.new("BodyThrust")
  3621. bodythrust.force = mass * -velocity
  3622. bodythrust.Parent = part
  3623. local bodyforce = Instance.new("BodyForce")
  3624. bodyforce.force = mass * Vector3.new(0, 196.2, 0)
  3625. bodyforce.Parent = part
  3626. part.Anchored = false
  3627. part.Reflectance = 1
  3628. part.RotVelocity = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5)
  3629. part.Transparency = 0.5
  3630. part.Velocity = (part.CFrame - part.Position) * velocity
  3631. end
  3632. for _, connection in ipairs(connections) do
  3633. connection:disconnect()
  3634. end
  3635. for i = 0, 99 do
  3636. Delay(i / 10, function()
  3637. for part in pairs(parts) do
  3638. local new_transparency = 0.5 * (1 + i / 50)
  3639. part.Reflectance = 0.98 * part.Reflectance
  3640. if new_transparency > part.Transparency then
  3641. part.Transparency = new_transparency
  3642. end
  3643. end
  3644. end)
  3645. end
  3646. Delay(10, function()
  3647. for part in pairs(parts) do
  3648. pcall(part.Destroy, part)
  3649. end
  3650. end)
  3651. end
  3652. function ControllerCommands.HugeExplosionOfDoomAtMouse()
  3653. ControllerCommands.HugeExplosionOfDoom(Mouse.Hit.p)
  3654. end
  3655.  
  3656. function ControllerCommands.SpaceHyperBeam(asd)
  3657. GraphicalEffects.SpaceHyperBeam(asd)
  3658. end
  3659. function ControllerCommands.SpaceHyperBeamAtMouse()
  3660. ControllerCommands.SpaceHyperBeam(Mouse.Hit.p)
  3661. end
  3662. function ControllerCommands.ConcentratedSpaceHyperBeamAtMouse()
  3663. local p = Mouse.Hit.p; for i = 1, 50 do GraphicalEffects.SpaceHyperBeam(p) end
  3664. end
  3665.  
  3666. function ControllerCommands.TeleportCharacterToMouse()
  3667. if PlayerControl.IsEnabled() then
  3668. local torso = PlayerControl.GetTorso()
  3669. if torso then
  3670. local pos = Mouse.Hit.p + Vector3.new(0, 5, 0)
  3671. torso.CFrame = CFrame.new(pos, pos + torso.CFrame.lookVector)
  3672. end
  3673. else
  3674. local new_focus_position = Mouse.Hit.p
  3675. local direction_vector = Camera.CoordinateFrame.lookVector
  3676. local new_focus = CFrame.new(new_focus_position, new_focus_position + direction_vector)
  3677. Camera.CoordinateFrame = new_focus * CFrame.new(0, 0, 25)
  3678. Camera.Focus = new_focus
  3679. end
  3680. end
  3681.  
  3682. AdvancedGUI = {};
  3683.  
  3684. if not AdvancedGUI.GUI_BASE_COLOR then
  3685. AdvancedGUI.GUI_BASE_COLOR = Color3.new(0, 0, 0)
  3686. end
  3687. function AdvancedGUI.GenerateChatColor(speakerName)
  3688. local chatColor = ChatColor.Get(speakerName).Color
  3689. local brightness = chatColor.r + chatColor.g + chatColor.b
  3690. if brightness < 1.5 then
  3691. chatColor = Color3.new(math.min(1, 0.4 + chatColor.r), math.min(1, 0.4 + chatColor.g), math.min(1, 0.4 + chatColor.b))
  3692. else
  3693. chatColor = Color3.new(math.min(1, 0.05 + chatColor.r), math.min(1, 0.05 + chatColor.g), math.min(1, 0.05 + chatColor.b))
  3694. end
  3695. return chatColor
  3696. end
  3697. GuiBase = {}
  3698. GuiBase.__index = GuiBase
  3699. function GuiBase:new(data)
  3700. local instance = setmetatable({}, self)
  3701. instance:Init(data)
  3702. return instance
  3703. end
  3704. function GuiBase:Destroy()
  3705. if self.parent then
  3706. self.parent.children[self] = nil
  3707. end
  3708. for child in pairs(self.children) do
  3709. child:Destroy()
  3710. end
  3711. self.m_base_instance:Destroy()
  3712. end
  3713. function GuiBase:GetContentInstance(child)
  3714. return self.m_base_instance
  3715. end
  3716. function GuiBase:Init()
  3717. self.children = {}
  3718. end
  3719. function GuiBase:IsA(className)
  3720. return className == "GuiBase"
  3721. end
  3722. function GuiBase:SetParent(parent)
  3723. if parent ~= self.parent then
  3724. if self.parent then
  3725. self.parent.children[self] = nil
  3726. end
  3727. self.parent = parent
  3728. if parent then
  3729. parent.children[self] = true
  3730. self.m_base_instance.Parent = parent:GetContentInstance()
  3731. else
  3732. self.m_base_instance.Parent = nil
  3733. end
  3734. end
  3735. end
  3736. GuiObject = setmetatable({}, GuiBase)
  3737. GuiObject.__index = GuiObject
  3738. function GuiObject:Destroy()
  3739. self.DragBegin:disconnect()
  3740. self.DragMove:disconnect()
  3741. self.DragStopped:disconnect()
  3742. self.MouseButton1Click:disconnect()
  3743. self.MouseButton1Down:disconnect()
  3744. self.MouseButton1Up:disconnect()
  3745. self.MouseButton2Down:disconnect()
  3746. self.MouseButton2Up:disconnect()
  3747. self.MouseEnter:disconnect()
  3748. self.MouseLeave:disconnect()
  3749. GuiBase.Destroy(self)
  3750. end
  3751. function GuiObject:GetAbsolutePosition()
  3752. return self.m_base_instance.AbsolutePosition
  3753. end
  3754. function GuiObject:GetAbsoluteSize()
  3755. return self.m_base_instance.AbsoluteSize
  3756. end
  3757. function GuiObject:GetPosition()
  3758. return self.position
  3759. end
  3760. function GuiObject:GetSize()
  3761. return self.size
  3762. end
  3763. function GuiObject:Init()
  3764. GuiBase.Init(self)
  3765. self.mouseDown = false
  3766. self.mouseOver = false
  3767. self.DragBegin = RbxUtility.CreateSignal()
  3768. self.DragMove = RbxUtility.CreateSignal()
  3769. self.DragStopped = RbxUtility.CreateSignal()
  3770. self.MouseButton1Click = RbxUtility.CreateSignal()
  3771. self.MouseButton1Down = RbxUtility.CreateSignal()
  3772. self.MouseButton1Up = RbxUtility.CreateSignal()
  3773. self.MouseButton2Down = RbxUtility.CreateSignal()
  3774. self.MouseButton2Up = RbxUtility.CreateSignal()
  3775. self.MouseEnter = RbxUtility.CreateSignal()
  3776. self.MouseLeave = RbxUtility.CreateSignal()
  3777. end
  3778. function GuiObject:IsA(className)
  3779. return className == "GuiObject" or GuiBase.IsA(self, className)
  3780. end
  3781. function GuiObject:SetActive(active)
  3782. if active ~= self.active then
  3783. self.active = active
  3784. end
  3785. end
  3786. function GuiObject:SetBackgroundTransparency(backgroundTransparency)
  3787. if backgroundTransparency ~= self.backgroundTransparency then
  3788. self.backgroundTransparency = backgroundTransparency
  3789. self.m_base_instance.BackgroundTransparency = backgroundTransparency
  3790. end
  3791. end
  3792. function GuiObject:SetColor(color)
  3793. if color ~= self.color then
  3794. self.color = color
  3795. self.m_base_instance.BackgroundColor3 = color
  3796. end
  3797. end
  3798. function GuiObject:SetPosition(position)
  3799. if position ~= self.position then
  3800. self.position = position
  3801. self.m_base_instance.Position = position
  3802. end
  3803. end
  3804. function GuiObject:SetSize(size)
  3805. if size ~= self.size then
  3806. self.size = size
  3807. self.m_base_instance.Size = size
  3808. end
  3809. end
  3810. function GuiObject:SetVisible(visible)
  3811. if visible ~= self.visible then
  3812. self.visible = visible
  3813. self.m_base_instance.Visible = visible
  3814. end
  3815. end
  3816. function GuiObject:SetZIndex(zIndex)
  3817. local stack = {self.m_base_instance}
  3818. repeat
  3819. local object = stack[#stack]
  3820. stack[#stack] = nil
  3821. for _, child in ipairs(object:GetChildren()) do
  3822. stack[#stack + 1] = child
  3823. end
  3824. object.ZIndex = zIndex
  3825. until #stack == 0
  3826. end
  3827. GuiServiceClass = setmetatable({}, GuiBase)
  3828. GuiServiceClass.__index = GuiServiceClass
  3829. function GuiServiceClass:CreateTextArea(text, font, fontSize, textColor3, textXAlignment, textYAlignment, maxWidth, minWidth)
  3830. local totalHeight = 0
  3831. local frame = Instance.new("Frame")
  3832. frame.BackgroundTransparency = 1
  3833. local label = Instance.new("TextLabel")
  3834. label.BackgroundTransparency = 1
  3835. label.Font = font
  3836. label.FontSize = fontSize
  3837. label.TextColor3 = textColor3
  3838. label.TextTransparency = 1
  3839. label.TextWrapped = true
  3840. label.TextXAlignment = textXAlignment
  3841. label.TextYAlignment = textYAlignment
  3842. label.Parent = self.guiFrame
  3843. local index = 1
  3844. while true do
  3845. local length = #text - index + 1
  3846. if length > 1024 then
  3847. length = 1024
  3848. local textBlock = string.sub(text, index, index + length - 1)
  3849. label.Text = textBlock
  3850. local height = 0
  3851. local width = maxWidth
  3852. repeat
  3853. height = height + 20
  3854. label.Size = UDim2.new(0, width, 0, height)
  3855. until label.TextFits
  3856. repeat
  3857. height = height - 1
  3858. label.Size = UDim2.new(0, width, 0, height)
  3859. until not label.TextFits
  3860. repeat
  3861. length = length - 10
  3862. label.Text = string.sub(text, index, index + length - 1)
  3863. until label.TextFits
  3864. repeat
  3865. length = length + 1
  3866. label.Text = string.sub(text, index, index + length - 1)
  3867. until not label.TextFits
  3868. local overflowCharacter = string.sub(text, index + length - 1, index + length - 1)
  3869. length = length - 1
  3870. label.Text = string.sub(text, index, index + length - 1)
  3871. if overflowCharacter == "\n" then
  3872. index = index + 1
  3873. end
  3874. repeat
  3875. height = height - 1
  3876. label.Size = UDim2.new(0, width, 0, height)
  3877. until not label.TextFits
  3878. height = height + 1
  3879. local blockLabel = label:Clone()
  3880. blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
  3881. blockLabel.Size = UDim2.new(1, 0, 0, height)
  3882. blockLabel.Parent = frame
  3883. totalHeight = totalHeight + height
  3884. index = index + length
  3885. else
  3886. local textBlock = string.sub(text, index)
  3887. label.Text = textBlock
  3888. local height = 0
  3889. local width = maxWidth
  3890. repeat
  3891. height = height + 20
  3892. label.Size = UDim2.new(0, width, 0, height)
  3893. until label.TextFits
  3894. repeat
  3895. height = height - 1
  3896. label.Size = UDim2.new(0, width, 0, height)
  3897. until not label.TextFits
  3898. height = height + 1
  3899. if index == 1 then
  3900. repeat
  3901. width = width - 10
  3902. label.Size = UDim2.new(0, width, 0, height)
  3903. until width < minWidth or not label.TextFits
  3904. width = math.max(width, minWidth - 1)
  3905. repeat
  3906. width = width + 1
  3907. label.Size = UDim2.new(0, width, 0, height)
  3908. until label.TextFits
  3909. end
  3910. local blockLabel = label:Clone()
  3911. blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
  3912. blockLabel.Size = UDim2.new(1, 0, 0, height)
  3913. blockLabel.Parent = frame
  3914. label:Destroy()
  3915. frame.Size = UDim2.new(0, width, 0, totalHeight + height)
  3916. return frame
  3917. end
  3918. end
  3919. end
  3920. function GuiServiceClass:Destroy()
  3921. self.running = false
  3922. self.cameraPart:Destroy()
  3923. self.cameraConnection:disconnect()
  3924. self.keyDownConnection:disconnect()
  3925. self.mouseButton1DownConnection:disconnect()
  3926. self.mouseButton1UpConnection:disconnect()
  3927. self.mouseButton2DownConnection:disconnect()
  3928. self.mouseButton2UpConnection:disconnect()
  3929. self.mouseMoveConnection:disconnect()
  3930. self.steppedConnection:disconnect()
  3931. end
  3932. function GuiServiceClass:GetMousePosition()
  3933. local mouse = self.mouse
  3934. return mouse.X, mouse.Y -- mouse.X, mouse.Y + 2 -- return mouse.X - 2, mouse.Y - 3
  3935. end
  3936. function GuiServiceClass:GetTextBounds(text, font, fontSize, alignX, alignY, width)
  3937. local tempLabel = self.tempLabel
  3938. tempLabel.Font = font
  3939. tempLabel.FontSize = fontSize
  3940. tempLabel.Size = UDim2.new(0, width, 0, 4096)
  3941. tempLabel.Text = text
  3942. tempLabel.TextXAlignment = alignX
  3943. tempLabel.TextYAlignment = alignY
  3944. local textBounds = tempLabel.TextBounds
  3945. tempLabel.Text = ""
  3946. return textBounds
  3947. end
  3948. function GuiServiceClass:Init(data)
  3949. GuiBase.Init(self)
  3950. local _ = string.char
  3951. local camera = data.Camera
  3952. local mouse = data.Mouse
  3953. local cameraPart = Instance.new("Part")
  3954. local billboardGui = Instance.new("BillboardGui", cameraPart)
  3955. guiFrame = Instance.new("Frame", billboardGui)
  3956. cameraPart.Anchored = true
  3957. cameraPart.BottomSurface = "Smooth"
  3958. cameraPart.CanCollide = false
  3959. -- cameraPart.CFrame = CFrame.new(16384, 16384, 16384)
  3960. cameraPart.FormFactor = "Custom"
  3961. cameraPart.Locked = true
  3962. cameraPart.Size = Vector3.new(0.2, 0.2, 0.2)
  3963. cameraPart.TopSurface = "Smooth"
  3964. cameraPart.Transparency = 1
  3965. billboardGui.Adornee = cameraPart
  3966. billboardGui.AlwaysOnTop = true
  3967. -- billboardGui.ExtentsOffset = Vector3.new(-16384, -16384, -16384)
  3968. guiFrame.BackgroundTransparency = 1
  3969. cameraPart.Parent = camera
  3970. self.running = true
  3971. self.m_base_instance = guiFrame
  3972. self.billboardGui = billboardGui
  3973. self.cameraPart = cameraPart
  3974. self.tempLabel = RBXInstance.new "TextLabel" {
  3975. BackgroundTransparency = 1,
  3976. TextTransparency = 1,
  3977. TextWrapped = true,
  3978. Parent = guiFrame
  3979. }
  3980. self.mnemonics = {}
  3981. self.visible = true
  3982. self.camera = camera
  3983. self.mouse = mouse
  3984. self.cameraConnection = camera.Changed:connect(function(property)
  3985. self:UpdateView()
  3986. if property == "CameraType" then
  3987. if camera.CameraType ~= Enum.CameraType.Track and camera.CameraType ~= Enum.CameraType.Fixed then
  3988. camera.CameraType = Enum.CameraType.Track
  3989. end
  3990. elseif property == "CoordinateFrame" and camera.CameraType ~= Enum.CameraType.Fixed then
  3991. local cframe, focus = camera.CoordinateFrame, camera.Focus
  3992. local watchOffset = focus.p - cframe.p
  3993. local error = watchOffset.unit - cframe.lookVector
  3994. if error.magnitude >= 1e-3 then
  3995. local head = PlayerControl.GetHead()
  3996. local time1, velocity1
  3997. if head then
  3998. time1 = time()
  3999. velocity1 = head.Velocity
  4000. end
  4001. if camera.Changed:wait() == "CoordinateFrame" then
  4002. local position = cframe.p
  4003. if head then
  4004. local time2 = time()
  4005. local velocity2 = head.Velocity
  4006. position = position + 0.5 * (velocity1 + velocity2) * (time2 - time1)
  4007. end
  4008. camera.CoordinateFrame = CFrame.new(position, camera.Focus.p)
  4009. end
  4010. end
  4011. end
  4012. end)
  4013. self.keyDownConnection = mouse.KeyDown:connect(function(key) self:KeyDown(key) end)
  4014. self.mouseButton1DownConnection = mouse.Button1Down:connect(function() self:MouseButton1Down() end)
  4015. self.mouseButton1UpConnection = mouse.Button1Up:connect(function() self:MouseButton1Up() end)
  4016. self.mouseButton2DownConnection = mouse.Button2Down:connect(function() self:MouseButton2Down() end)
  4017. self.mouseButton2UpConnection = mouse.Button2Up:connect(function() self:MouseButton2Up() end)
  4018. self.mouseMoveConnection = mouse.Move:connect(function() self:MouseMove() end)
  4019. self.steppedConnection = RunService.RenderStepped:connect(function() self:UpdateObjects() self:UpdateView() end)
  4020. self.mousePreviousPosition = Vector2.new(self:GetMousePosition())
  4021. end
  4022. function GuiServiceClass:IsA(className)
  4023. return className == "GuiService" or GuiBase.IsA(self, className)
  4024. end
  4025. function GuiServiceClass:KeyDown(key)
  4026. local mnemonicButton = self.mnemonics[string.upper(key)]
  4027. if mnemonicButton then
  4028. mnemonicButton.Activated:fire()
  4029. end
  4030. end
  4031. function GuiServiceClass:MouseButton1Down()
  4032. local mouse = self.mouse
  4033. local mouseX, mouseY = self:GetMousePosition()
  4034. local stack = {self}
  4035. local dragObjects = {}
  4036. self.dragObjects = dragObjects
  4037. while #stack > 0 do
  4038. local object = stack[#stack]
  4039. stack[#stack] = nil
  4040. if object.visible then
  4041. for child in pairs(object.children) do
  4042. stack[#stack + 1] = child
  4043. end
  4044. if object.active then
  4045. local position = object:GetAbsolutePosition()
  4046. local size = object:GetAbsoluteSize()
  4047. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4048. object.mouseDown = true
  4049. dragObjects[object] = true
  4050. local mouseButton1Down = object.MouseButton1Down
  4051. if mouseButton1Down then
  4052. mouseButton1Down:fire()
  4053. if object.autoButtonColor then
  4054. local color = object.color
  4055. local transparency = object.backgroundTransparency
  4056. object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g +
  4057.  
  4058. 0.3, 1), math.min(color.b + 0.3, 1))
  4059. object.m_base_instance.BackgroundTransparency = transparency
  4060. end
  4061. end
  4062. object.DragBegin:fire()
  4063. end
  4064. end
  4065. end
  4066. end
  4067. self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
  4068. end
  4069. function GuiServiceClass:MouseButton1Up()
  4070. local mouse = self.mouse
  4071. local mouseX, mouseY = self:GetMousePosition()
  4072. local stack = {self}
  4073. while #stack > 0 do
  4074. local object = stack[#stack]
  4075. stack[#stack] = nil
  4076. if object.visible then
  4077. for child in pairs(object.children) do
  4078. stack[#stack + 1] = child
  4079. end
  4080. if object.active then
  4081. local position = object:GetAbsolutePosition()
  4082. local size = object:GetAbsoluteSize()
  4083. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4084. object.MouseButton1Up:fire()
  4085. end
  4086. end
  4087. end
  4088. end
  4089. local dragObjects = self.dragObjects
  4090. self.dragObjects = nil
  4091. if dragObjects then
  4092. for dragObject in pairs(dragObjects) do
  4093. dragObject.mouseDown = false
  4094. local position = dragObject:GetAbsolutePosition()
  4095. local size = dragObject:GetAbsoluteSize()
  4096. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4097. dragObject.MouseButton1Click:fire()
  4098. local activated = dragObject.Activated
  4099. if activated then
  4100. activated:fire()
  4101. end
  4102. end
  4103. dragObject.DragStopped:fire()
  4104. if dragObject.autoButtonColor then
  4105. if dragObject.mouseOver then
  4106. local color = dragObject.color
  4107. local transparency = dragObject.backgroundTransparency
  4108. dragObject.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0),
  4109.  
  4110. math.max(color.b - 0.3, 0))
  4111. dragObject.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
  4112. else
  4113. dragObject.m_base_instance.BackgroundColor3 = dragObject.color
  4114. dragObject.m_base_instance.BackgroundTransparency = dragObject.backgroundTransparency
  4115. end
  4116. end
  4117. self.dragObject = nil
  4118. end
  4119. end
  4120. end
  4121. function GuiServiceClass:MouseButton2Down()
  4122. local mouse = self.mouse
  4123. local mouseX, mouseY = self:GetMousePosition()
  4124. local stack = {self}
  4125. while #stack > 0 do
  4126. local object = stack[#stack]
  4127. stack[#stack] = nil
  4128. if object.visible then
  4129. for child in pairs(object.children) do
  4130. stack[#stack + 1] = child
  4131. end
  4132. if object.active then
  4133. local position = object:GetAbsolutePosition()
  4134. local size = object:GetAbsoluteSize()
  4135. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4136. local mouseButton2Down = object.MouseButton2Down
  4137. if mouseButton2Down then
  4138. mouseButton2Down:fire()
  4139. end
  4140. end
  4141. end
  4142. end
  4143. end
  4144. self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
  4145. end
  4146. function GuiServiceClass:MouseButton2Up()
  4147. local mouse = self.mouse
  4148. local mouseX, mouseY = self:GetMousePosition()
  4149. local stack = {self}
  4150. while #stack > 0 do
  4151. local object = stack[#stack]
  4152. stack[#stack] = nil
  4153. if object.visible then
  4154. for child in pairs(object.children) do
  4155. stack[#stack + 1] = child
  4156. end
  4157. if object.active then
  4158. local position = object:GetAbsolutePosition()
  4159. local size = object:GetAbsoluteSize()
  4160. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4161. local mouseButton2Up = object.MouseButton2Up
  4162. if mouseButton2Up then
  4163. mouseButton2Up:fire()
  4164. end
  4165. end
  4166. end
  4167. end
  4168. end
  4169. end
  4170. function GuiServiceClass:MouseMove()
  4171. self:UpdateObjects()
  4172. local dragObjects = self.dragObjects
  4173. if dragObjects then
  4174. for dragObject in pairs(dragObjects) do
  4175. local mouse = self.mouse
  4176. local mousePosition = Vector2.new(self:GetMousePosition())
  4177. dragObject.DragMove:fire(mousePosition - self.mousePreviousPosition)
  4178. self.mousePreviousPosition = mousePosition
  4179. end
  4180. end
  4181. end
  4182. function GuiServiceClass:SetMnemonic(mnemonic, button)
  4183. self.mnemonics[mnemonic] = button
  4184. end
  4185. function GuiServiceClass:UpdateObjects()
  4186. local mouse = self.mouse
  4187. local mouseX, mouseY = self:GetMousePosition()
  4188. local stack = {self}
  4189. while #stack > 0 do
  4190. local object = stack[#stack]
  4191. stack[#stack] = nil
  4192. if object.visible then
  4193. for child in pairs(object.children) do
  4194. stack[#stack + 1] = child
  4195. end
  4196. if object.active then
  4197. local position = object:GetAbsolutePosition()
  4198. local size = object:GetAbsoluteSize()
  4199. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  4200. if not object.mouseOver then
  4201. object.mouseOver = true
  4202. object.MouseEnter:fire()
  4203. if object.autoButtonColor then
  4204. local color = object.color
  4205. local transparency = object.backgroundTransparency
  4206. if object.mouseDown then
  4207. object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 0.3, 1), math.min(color.b + 0.3, 1))
  4208. object.m_base_instance.BackgroundTransparency = transparency
  4209. else
  4210. object.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), math.max(color.b - 0.3, 0))
  4211. object.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
  4212. end
  4213. end
  4214. end
  4215. else
  4216. if object.mouseOver then
  4217. object.mouseOver = false
  4218. object.MouseLeave:fire()
  4219. if object.autoButtonColor then
  4220. object.m_base_instance.BackgroundColor3 = object.color
  4221. object.m_base_instance.BackgroundTransparency = object.backgroundTransparency
  4222. end
  4223. end
  4224. end
  4225. end
  4226. end
  4227. end
  4228. end
  4229. function GuiServiceClass:UpdateView()
  4230. local billboardGui = self.billboardGui
  4231. local guiFrame = self.m_base_instance
  4232. local camera = self.camera
  4233. local mouse = self.mouse
  4234. local cameraCFrame = CFrame.new(camera.CoordinateFrame.p, camera.Focus.p) -- camera.CoordinateFrame
  4235. local viewSizeX, viewSizeY = mouse.ViewSizeX, mouse.ViewSizeY
  4236. local previousViewSize = self.viewSize
  4237. if not previousViewSize or ((viewSizeX ~= 0 or viewSizeY ~= 0) and (viewSizeX ~= previousViewSize.X or viewSizeY ~= previousViewSize.Y)) then
  4238. self.viewSize = {X = viewSizeX, Y = viewSizeY}
  4239. local viewSizeUDim2 = UDim2.new(0, viewSizeX, 0, viewSizeY)
  4240. billboardGui.Size = viewSizeUDim2
  4241. guiFrame.Size = viewSizeUDim2
  4242. -- FIXME:
  4243. -- After the 15th of July 2014, there came an offset at the Y thingy out of nowhere so I accomodated for that.
  4244. billboardGui.SizeOffset = Vector2.new(0.5 / viewSizeX, (0.5 + 10) / viewSizeY)
  4245. end
  4246. --billboardGui.SizeOffset = Vector2.new()
  4247. billboardGui.StudsOffset = (cameraCFrame - cameraCFrame.p):inverse() * cameraCFrame.p - Vector3.new(0, 0, 1)
  4248. end
  4249. GuiService = GuiServiceClass:new {
  4250. Camera = Camera,
  4251. Mouse = Mouse
  4252. }
  4253. GuiFrame = setmetatable({}, GuiObject)
  4254. GuiFrame.__index = GuiFrame
  4255. GuiFrame.__default = {__index = {
  4256. Active = false,
  4257. BackgroundTransparency = 0.75,
  4258. BorderSize = 4,
  4259. BorderTransparency = 0.75,
  4260. Color = AdvancedGUI.GUI_BASE_COLOR,
  4261. Position = UDim2.new(0, 0, 0, 0),
  4262. Size = UDim2.new(0, 52, 0, 52),
  4263. Visible = true
  4264. }}
  4265. function GuiFrame:Destroy()
  4266. GuiObject.Destroy(self)
  4267. end
  4268. function GuiFrame:GetContentInstance()
  4269. return self.m_content_frame
  4270. end
  4271. function GuiFrame:Init(data)
  4272. GuiObject.Init(self)
  4273. setmetatable(data, GuiFrame.__default)
  4274. local leftBorderFrameLeft = RBXInstance.new "Frame" {
  4275. BackgroundColor3 = Color3.new(0, 0, 0),
  4276. BorderSizePixel = 0,
  4277. Size = UDim2.new(0, 1, 1, -1)
  4278. }
  4279. local leftBorderFrameCenter = RBXInstance.new "Frame" {
  4280. BackgroundColor3 = Color3.new(1, 1, 1),
  4281. BorderSizePixel = 0,
  4282. Position = UDim2.new(0, 1, 0, 1)
  4283. }
  4284. local leftBorderFrameRight = RBXInstance.new "Frame" {
  4285. BackgroundColor3 = Color3.new(0, 0, 0),
  4286. BorderSizePixel = 0
  4287. }
  4288. local rightBorderFrameRight = RBXInstance.new "Frame" {
  4289. BackgroundColor3 = Color3.new(0, 0, 0),
  4290. BorderSizePixel = 0,
  4291. Position = UDim2.new(1, -1, 0, 1),
  4292. Size = UDim2.new(0, 1, 1, -1)
  4293. }
  4294. local rightBorderFrameCenter = RBXInstance.new "Frame" {
  4295. BackgroundColor3 = Color3.new(1, 1, 1),
  4296. BorderSizePixel = 0
  4297. }
  4298. local rightBorderFrameLeft = RBXInstance.new "Frame" {
  4299. BackgroundColor3 = Color3.new(0, 0, 0),
  4300. BorderSizePixel = 0
  4301. }
  4302. local bottomBorderFrameBottom = RBXInstance.new "Frame" {
  4303. BackgroundColor3 = Color3.new(0, 0, 0),
  4304. BorderSizePixel = 0,
  4305. Position = UDim2.new(0, 0, 1, -1),
  4306. Size = UDim2.new(1, -1, 0, 1)
  4307. }
  4308. local bottomBorderFrameCenter = RBXInstance.new "Frame" {
  4309. BackgroundColor3 = Color3.new(1, 1, 1),
  4310. BorderSizePixel = 0
  4311. }
  4312. local bottomBorderFrameTop = RBXInstance.new "Frame" {
  4313. BackgroundColor3 = Color3.new(0, 0, 0),
  4314. BorderSizePixel = 0
  4315. }
  4316. local topBorderFrameTop = RBXInstance.new "Frame" {
  4317. BackgroundColor3 = Color3.new(0, 0, 0),
  4318. BorderSizePixel = 0,
  4319. Position = UDim2.new(0, 1, 0, 0),
  4320. Size = UDim2.new(1, -1, 0, 1)
  4321. }
  4322. local topBorderFrameCenter = RBXInstance.new "Frame" {
  4323. BackgroundColor3 = Color3.new(1, 1, 1),
  4324. BorderSizePixel = 0
  4325. }
  4326. local topBorderFrameBottom = RBXInstance.new "Frame" {
  4327. BackgroundColor3 = Color3.new(0, 0, 0),
  4328. BorderSizePixel = 0
  4329. }
  4330. local border_frame = RBXInstance.new "Frame" {
  4331. BackgroundTransparency = 1,
  4332. Size = UDim2.new(1, 0, 1, 0),
  4333. leftBorderFrameLeft,
  4334. leftBorderFrameCenter,
  4335. leftBorderFrameRight,
  4336. rightBorderFrameLeft,
  4337. rightBorderFrameCenter,
  4338. rightBorderFrameRight,
  4339. bottomBorderFrameBottom,
  4340. bottomBorderFrameCenter,
  4341. bottomBorderFrameTop,
  4342. topBorderFrameBottom,
  4343. topBorderFrameCenter,
  4344. topBorderFrameTop
  4345. }
  4346. local contentFrame = RBXInstance.new "Frame" {
  4347. BackgroundTransparency = 1,
  4348. BorderSizePixel = 0,
  4349. ClipsDescendants = true,
  4350. Size = UDim2.new(1, 0, 1, 0)
  4351. }
  4352. local base_frame = RBXInstance.new "Frame" {
  4353. BorderSizePixel = 0,
  4354. border_frame,
  4355. contentFrame
  4356. }
  4357. self.m_base_instance = base_frame
  4358. self.m_content_frame = contentFrame
  4359. self.m_border_frame = border_frame
  4360. self.leftBorderFrameLeft = leftBorderFrameLeft
  4361. self.leftBorderFrameCenter = leftBorderFrameCenter
  4362. self.leftBorderFrameRight = leftBorderFrameRight
  4363. self.rightBorderFrameLeft = rightBorderFrameLeft
  4364. self.rightBorderFrameCenter = rightBorderFrameCenter
  4365. self.rightBorderFrameRight = rightBorderFrameRight
  4366. self.bottomBorderFrameBottom = bottomBorderFrameBottom
  4367. self.bottomBorderFrameCenter = bottomBorderFrameCenter
  4368. self.bottomBorderFrameTop = bottomBorderFrameTop
  4369. self.topBorderFrameBottom = topBorderFrameBottom
  4370. self.topBorderFrameCenter = topBorderFrameCenter
  4371. self.topBorderFrameTop = topBorderFrameTop
  4372. self:SetActive(data.Active)
  4373. self:SetBackgroundTransparency(data.BackgroundTransparency)
  4374. self:SetBorderSize(data.BorderSize)
  4375. self:SetBorderTransparency(data.BorderTransparency)
  4376. self:SetColor(data.Color)
  4377. self:SetPosition(data.Position)
  4378. self:SetSize(data.Size)
  4379. self:SetVisible(data.Visible)
  4380. self:SetParent(data.Parent)
  4381. end
  4382. function GuiFrame:IsA(className)
  4383. return className == "GuiFrame" or GuiObject.IsA(self, className)
  4384. end
  4385. function GuiFrame:SetBorderSize(border_size)
  4386. border_size = math.max(math.floor(border_size + 0.5), 0)
  4387. if border_size ~= self.m_border_size then
  4388. self.m_border_size = border_size
  4389. local border_frame = self.m_border_frame
  4390. local contentFrame = self.m_content_frame
  4391. local leftBorderFrameCenter = self.leftBorderFrameCenter
  4392. local leftBorderFrameRight = self.leftBorderFrameRight
  4393. local rightBorderFrameCenter = self.rightBorderFrameCenter
  4394. local rightBorderFrameLeft = self.rightBorderFrameLeft
  4395. local bottomBorderFrameCenter = self.bottomBorderFrameCenter
  4396. local bottomBorderFrameTop = self.bottomBorderFrameTop
  4397. local topBorderFrameCenter = self.topBorderFrameCenter
  4398. local topBorderFrameBottom = self.topBorderFrameBottom
  4399. contentFrame.Position = UDim2.new(0, border_size, 0, border_size)
  4400. contentFrame.Size = UDim2.new(1, -2 * border_size, 1, -2 * border_size)
  4401. local inner_visible = border_size > 0
  4402. if self.leftBorderFrameLeft.Visible ~= inner_visible then
  4403. self.rightBorderFrameRight.Visible = inner_visible
  4404. self.bottomBorderFrameBottom.Visible = inner_visible
  4405. self.topBorderFrameTop.Visible = inner_visible
  4406. end
  4407. local outer_visible = border_size > 1
  4408. if leftBorderFrameCenter.Visible ~= outer_visible then
  4409. leftBorderFrameCenter.Visible = outer_visible
  4410. leftBorderFrameRight.Visible = outer_visible
  4411. rightBorderFrameCenter.Visible = outer_visible
  4412. rightBorderFrameLeft.Visible = outer_visible
  4413. bottomBorderFrameCenter.Visible = outer_visible
  4414. bottomBorderFrameTop.Visible = outer_visible
  4415. topBorderFrameCenter.Visible = outer_visible
  4416. topBorderFrameBottom.Visible = outer_visible
  4417. end
  4418. if outer_visible then
  4419. leftBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
  4420. leftBorderFrameRight.Position = UDim2.new(0, border_size - 1, 0, border_size - 1)
  4421. leftBorderFrameRight.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
  4422. rightBorderFrameCenter.Position = UDim2.new(1, 1 - border_size, 0, border_size - 1)
  4423. rightBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
  4424. rightBorderFrameLeft.Position = UDim2.new(1, -border_size, 0, border_size)
  4425. rightBorderFrameLeft.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
  4426. bottomBorderFrameCenter.Position = UDim2.new(0, 1, 1, 1 - border_size)
  4427. bottomBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
  4428. bottomBorderFrameTop.Position = UDim2.new(0, border_size - 1, 1, -border_size)
  4429. bottomBorderFrameTop.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
  4430. topBorderFrameCenter.Position = UDim2.new(0, border_size - 1, 0, 1)
  4431. topBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
  4432. topBorderFrameBottom.Position = UDim2.new(0, border_size, 0, border_size - 1)
  4433. topBorderFrameBottom.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
  4434. end
  4435. end
  4436. end
  4437. function GuiFrame:SetBorderTransparency(borderTransparency)
  4438. self.borderTransparency = borderTransparency
  4439. self.leftBorderFrameLeft.BackgroundTransparency = borderTransparency
  4440. self.leftBorderFrameCenter.BackgroundTransparency = borderTransparency
  4441. self.leftBorderFrameRight.BackgroundTransparency = borderTransparency
  4442. self.rightBorderFrameLeft.BackgroundTransparency = borderTransparency
  4443. self.rightBorderFrameCenter.BackgroundTransparency = borderTransparency
  4444. self.rightBorderFrameRight.BackgroundTransparency = borderTransparency
  4445. self.bottomBorderFrameBottom.BackgroundTransparency = borderTransparency
  4446. self.bottomBorderFrameCenter.BackgroundTransparency = borderTransparency
  4447. self.bottomBorderFrameTop.BackgroundTransparency = borderTransparency
  4448. self.topBorderFrameBottom.BackgroundTransparency = borderTransparency
  4449. self.topBorderFrameCenter.BackgroundTransparency = borderTransparency
  4450. self.topBorderFrameTop.BackgroundTransparency = borderTransparency
  4451. end
  4452. GuiButton = setmetatable({}, GuiFrame)
  4453. GuiButton.__index = GuiButton
  4454. GuiButton.__default = {__index = {
  4455. AutoButtonColor = true
  4456. }}
  4457. function GuiButton:Destroy()
  4458. self.Activated:disconnect()
  4459. GuiFrame.Destroy(self)
  4460. end
  4461. function GuiButton:Init(data)
  4462. if data.Active == nil then
  4463. data.Active = true
  4464. end
  4465. GuiFrame.Init(self, data)
  4466. setmetatable(data, GuiButton.__default)
  4467. self.Activated = RbxUtility.CreateSignal()
  4468. self:SetAutoButtonColor(data.AutoButtonColor)
  4469. end
  4470. function GuiButton:IsA(className)
  4471. return className == "GuiButton" or GuiFrame.IsA(self, className)
  4472. end
  4473. function GuiButton:SetAutoButtonColor(autoButtonColor)
  4474. if autoButtonColor ~= self.autoButtonColor then
  4475. self.autoButtonColor = autoButtonColor
  4476. if autoButtonColor then
  4477. if self.mouseOver then
  4478. local color = self.color
  4479. local transparency = self.backgroundTransparency
  4480. if self.mouseDown then
  4481. self.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 0.3, 1), math.min(color.b + 0.3, 1))
  4482. self.m_base_instance.BackgroundTransparency = transparency
  4483. else
  4484. self.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), math.max(color.b - 0.3, 0))
  4485. self.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.5)
  4486. end
  4487. end
  4488. else
  4489. self.m_base_instance.BackgroundColor3 = self.color
  4490. end
  4491. end
  4492. end
  4493. GuiTextLabel = setmetatable({}, GuiFrame)
  4494. GuiTextLabel.__index = GuiTextLabel
  4495. GuiTextLabel.__default = {__index = {
  4496. Font = "ArialBold",
  4497. FontSize = "Size12",
  4498. Text = "",
  4499. TextColor = Color3.new(1, 1, 1),
  4500. TextStrokeColor = Color3.new(0, 0, 0),
  4501. TextStrokeTransparency = 0.6,
  4502. TextWrapped = true
  4503. }}
  4504. function GuiTextLabel:Destroy()
  4505. GuiFrame.Destroy(self)
  4506. end
  4507. function GuiTextLabel:Init(data)
  4508. GuiFrame.Init(self, data)
  4509. setmetatable(data, GuiTextLabel.__default)
  4510. local base_instance = self.m_base_instance
  4511. local textLabel = RBXInstance.new "TextLabel" {
  4512. BackgroundTransparency = 1,
  4513. Font = data.Font,
  4514. FontSize = data.FontSize,
  4515. TextColor3 = data.TextColor3,
  4516. TextStrokeColor3 = data.TextStrokeColor3,
  4517. TextStrokeTransparency = data.TextStrokeTransparency,
  4518. TextWrapped = data.TextWrapped
  4519. }
  4520. textLabel.Parent = self:GetContentInstance()
  4521. self.textLabel = textLabel
  4522. self:SetText(data.Text)
  4523. end
  4524. function GuiTextLabel:IsA(className)
  4525. return className == "GuiTextLabel" or GuiFrame.IsA(self, className)
  4526. end
  4527. function GuiTextLabel:SetText(text)
  4528. if text ~= self.text then
  4529. self.text = text
  4530. local text_index = 1
  4531. local content_instance = self:GetContentInstance()
  4532. local content_instance_size = content_instance.AbsoluteSize
  4533. local frame = Instance.new("Frame")
  4534. frame.BackgroundTransparency = 1
  4535. local label = Instance.new("TextLabel")
  4536. label.BackgroundTransparency = 1
  4537. label.Font = font
  4538. label.FontSize = fontSize
  4539. label.Size = UDim2.new(0, content_instance_size.X, 0, 1000)
  4540. label.Text = ""
  4541. label.TextColor3 = textColor3
  4542. label.TextTransparency = 1
  4543. label.TextWrapped = true
  4544. label.TextXAlignment = textXAlignment
  4545. label.TextYAlignment = textYAlignment
  4546. label.Parent = self.guiFrame
  4547. local row_length = 0
  4548. local step_size = 256
  4549. for step = 1, 8 do
  4550. step_size = 0.5 * step_size
  4551. label.Text = string.sub(text, text_index, text_index + row_length - 1)
  4552. end
  4553. end
  4554. end
  4555. GuiImageButton = setmetatable({}, GuiButton)
  4556. GuiImageButton.__index = GuiImageButton
  4557. GuiImageButton.__default = {__index = {
  4558. Image = ""
  4559. }}
  4560. function GuiImageButton:Destroy()
  4561. GuiButton.Destroy(self)
  4562. end
  4563. function GuiImageButton:Init(data)
  4564. GuiButton.Init(self, data)
  4565. setmetatable(data, GuiImageButton.__default)
  4566. local content_frame = self.m_content_frame
  4567. local image_label = RBXInstance.new "ImageLabel" {
  4568. BackgroundTransparency = 1,
  4569. Size = UDim2.new(1, 0, 1, 0)
  4570. }
  4571. image_label.Parent = content_frame
  4572. self.m_image_label = image_label
  4573. self:SetImage(data.Image)
  4574. end
  4575. function GuiImageButton:IsA(className)
  4576. return className == "GuiImageButton" or GuiButton.IsA(self, className)
  4577. end
  4578. function GuiImageButton:SetImage(image)
  4579. if image ~= self.m_image then
  4580. self.m_image = image
  4581. self.m_image_label.Image = image
  4582. end
  4583. end
  4584. GuiTextButton = setmetatable({}, GuiButton)
  4585. GuiTextButton.__index = GuiTextButton
  4586. GuiTextButton.__default = {__index = {
  4587. Font = Enum.Font.ArialBold,
  4588. FontSize = Enum.FontSize.Size11,
  4589. Text = "Button",
  4590. TextXAlignment = Enum.TextXAlignment.Center
  4591. }}
  4592. function GuiTextButton:Destroy()
  4593. GuiButton.Destroy(self)
  4594. end
  4595. function GuiTextButton:GetTextBounds()
  4596. return self.textLabel.TextBounds
  4597. end
  4598. function GuiTextButton:Init(data)
  4599. GuiButton.Init(self, data)
  4600. setmetatable(data, GuiTextButton.__default)
  4601. local contentFrame = self.m_content_frame
  4602. local mnemonicLabel = RBXInstance.new "TextLabel" {
  4603. BackgroundTransparency = 1,
  4604. Font = "ArialBold",
  4605. FontSize = "Size36",
  4606. Size = UDim2.new(1, 0, 0.7, 0),
  4607. TextColor3 = Color3.new(1, 1, 1),
  4608. TextStrokeColor3 = Color3.new(0, 0, 0),
  4609. TextStrokeTransparency = 0.6,
  4610. TextWrapped = true
  4611. }
  4612. local textLabel = RBXInstance.new "TextLabel" {
  4613. BackgroundTransparency = 1,
  4614. TextColor3 = Color3.new(1, 1, 1),
  4615. TextStrokeColor3 = Color3.new(0, 0, 0),
  4616. TextStrokeTransparency = 0.6,
  4617. TextWrapped = true
  4618. }
  4619. mnemonicLabel.Parent = contentFrame
  4620. textLabel.Parent = contentFrame
  4621. self.mnemonicLabel = mnemonicLabel
  4622. self.textLabel = textLabel
  4623. self:SetFont(data.Font)
  4624. self:SetFontSize(data.FontSize)
  4625. self:SetMnemonic(data.Mnemonic, true)
  4626. self:SetText(data.Text)
  4627. self:SetTextXAlignment(data.TextXAlignment)
  4628. end
  4629. function GuiTextButton:IsA(className)
  4630. return className == "GuiTextButton" or GuiButton.IsA(self, className)
  4631. end
  4632. function GuiTextButton:SetFont(font)
  4633. if font ~= self.font then
  4634. self.font = font
  4635. self.textLabel.Font = font
  4636. end
  4637. end
  4638. function GuiTextButton:SetFontSize(fontSize)
  4639. if fontSize ~= self.fontSize then
  4640. self.fontSize = fontSize
  4641. self.textLabel.FontSize = fontSize
  4642. end
  4643. end
  4644. function GuiTextButton:SetMnemonic(mnemonic, forceUpdate)
  4645. if mnemonic ~= self.mnemonic or forceUpdate then
  4646. if self.mnemonic then
  4647. GuiService:SetMnemonic(self.mnemonic, nil)
  4648. end
  4649. if mnemonic then
  4650. GuiService:SetMnemonic(mnemonic, self)
  4651. end
  4652. self.mnemonic = mnemonic
  4653. local mnemonicLabel = self.mnemonicLabel
  4654. local textLabel = self.textLabel
  4655. if mnemonic then
  4656. mnemonicLabel.Text = mnemonic
  4657. textLabel.Size = UDim2.new(1, 0, 0.9, 0)
  4658. textLabel.TextYAlignment = "Bottom"
  4659. else
  4660. mnemonicLabel.Text = ""
  4661. textLabel.Size = UDim2.new(1, 0, 1, 0)
  4662. textLabel.TextYAlignment = "Center"
  4663. end
  4664. end
  4665. end
  4666. function GuiTextButton:SetText(text)
  4667. if text ~= self.text then
  4668. self.text = text
  4669. self.textLabel.Text = text
  4670. end
  4671. end
  4672. function GuiTextButton:SetTextXAlignment(textXAlignment)
  4673. if textXAlignment ~= self.textXAlignment then
  4674. self.textXAlignment = textXAlignment
  4675. self.textLabel.TextXAlignment = textXAlignment
  4676. end
  4677. end
  4678. GuiWindow = setmetatable({}, GuiObject)
  4679. GuiWindow.__index = GuiWindow
  4680. GuiWindow.__default = {__index = {
  4681. Active = true,
  4682. BackgroundTransparency = 0.5,
  4683. BorderSize = 4,
  4684. BorderTransparency = 0.5,
  4685. Position = UDim2.new(0, 0, 0, 0),
  4686. Size = UDim2.new(0, 360, 0, 240),
  4687. Title = "Window",
  4688. TitleBarBackgroundTransparency = 0.5,
  4689. TitleBarBorderTransparency = 1,
  4690. Visible = true
  4691. }}
  4692. function GuiWindow:Init(data)
  4693. GuiObject.Init(self)
  4694. setmetatable(data, GuiFrame.__default)
  4695. local title_bar = GuiTextLabel:new {
  4696. BackgroundTransparency = data.TitleBarBackgroundTransparency,
  4697. BorderTransparency = data.TitleBarBackgroundTransparency,
  4698. Text = data.Title
  4699. }
  4700. local content_frame = GuiFrame:new {
  4701. Active = data.Active,
  4702. BackgroundTransparency = data.BackgroundTransparency,
  4703. BorderSize = data.BorderSize,
  4704. BorderTransparency = data.BorderTransparency
  4705. }
  4706. local base_frame = RBXInstance.new "Frame" {
  4707. BackgroundTransparency = 1,
  4708. BorderSizePixel = 0,
  4709. Position = data.Position,
  4710. Size = data.Size,
  4711. Visible = data.Visible
  4712. }
  4713. self.m_base_frame = base_frame
  4714. self.m_content_frame = content_frame
  4715. self.m_title_bar = title_bar
  4716. end
  4717. function GuiWindow:IsA(className)
  4718. return className == "GuiWindow" or GuiObject.IsA(self, className)
  4719. end
  4720. GuiScrollFrame = setmetatable({}, GuiFrame)
  4721. GuiScrollFrame.__index = GuiScrollFrame
  4722. GuiScrollFrame.__default = {__index = {
  4723. ContentHeight = 0,
  4724. ScrollBarColor = Color3.new(1, 1, 1)
  4725. }}
  4726. function GuiScrollFrame:Destroy()
  4727. self.m_scroll_bar:Destroy()
  4728. GuiFrame.Destroy(self)
  4729. end
  4730. function GuiScrollFrame:GetContentInstance()
  4731. return self.m_scroll_frame or GuiFrame.GetContentInstance(self)
  4732. end
  4733. function GuiScrollFrame:Init(data)
  4734. GuiFrame.Init(self, data)
  4735. setmetatable(data, GuiScrollFrame.__default)
  4736. local scroll_pane = RBXInstance.new "Frame" {
  4737. BackgroundColor3 = Color3.new(1, 1, 1),
  4738. BackgroundTransparency = 0.8,
  4739. BorderSizePixel = 0,
  4740. Position = UDim2.new(1, -20, 0, 0),
  4741. Size = UDim2.new(0, 20, 1, 0),
  4742. Parent = self.m_content_frame
  4743. }
  4744. local scroll_bar = GuiFrame:new {
  4745. Active = true,
  4746. BackgroundTransparency = 0.6,
  4747. BorderTransparency = 0.6,
  4748. Color = data.ScrollBarColor,
  4749. Parent = self
  4750. }
  4751. local scroll_frame = RBXInstance.new "Frame" {
  4752. BackgroundTransparency = 1,
  4753. Parent = self.m_content_frame
  4754. }
  4755. self.m_scroll_bar = scroll_bar
  4756. self.m_scroll_frame = scroll_frame
  4757. self.m_scroll_pane = scroll_pane
  4758. self.m_scroll_position = 0
  4759. self.m_updating_content_height = false
  4760. self:SetContentHeight(data.ContentHeight)
  4761. self:UpdateScrollPosition()
  4762. self.m_scroll_bar.DragBegin:connect(function()
  4763. self.m_scroll_drag_total = Vector2.new()
  4764. self.m_scroll_initial_position = self.m_scroll_position
  4765. end)
  4766. self.m_scroll_bar.DragMove:connect(function(offset)
  4767. self.m_scroll_drag_total = self.m_scroll_drag_total + offset
  4768. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4769. if absolute_height ~= 0 then
  4770. local content_height = math.max(self.m_content_height, absolute_height)
  4771. local scroll_space = 1 - absolute_height / content_height
  4772. self:Scroll(self.m_scroll_initial_position + self.m_scroll_drag_total.Y * (content_height / absolute_height - 1) / scroll_space)
  4773. end
  4774. end)
  4775. end
  4776. function GuiScrollFrame:IsA(className)
  4777. return className == "GuiScrollFrame" or GuiFrame.IsA(self, className)
  4778. end
  4779. function GuiScrollFrame:Scroll(position)
  4780. position = math.min(math.max(position, 0), self.m_content_height - (self:GetAbsoluteSize().Y - 2 * self.m_border_size))
  4781. if position ~= self.m_scroll_position then
  4782. self.m_scroll_position = position
  4783. self:UpdateScrollPosition()
  4784. end
  4785. end
  4786. function GuiScrollFrame:SetContentHeight(height)
  4787. if height ~= self.m_content_height then
  4788. local prev_height = self.m_content_height
  4789. self.m_content_height = height
  4790. if not self.m_updating_content_height then
  4791. self.m_updating_content_height = true
  4792. coroutine.resume(coroutine.create(function()
  4793. local success, message = ypcall(self.SetContentHeightImpl1, self, prev_height)
  4794. if not success then
  4795. Logger.printf("Severe", "Error in GuiScrollFrame:SetContentHeight(%s): %s", Utility.ToString(height), message)
  4796. end
  4797. end))
  4798. end
  4799. end
  4800. end
  4801. function GuiScrollFrame:SetContentHeightImpl1(prev_height)
  4802. RunService.RenderStepped:wait()
  4803. self.m_updating_content_height = false
  4804. local height = self.m_content_height
  4805. self.m_scroll_frame.Size = UDim2.new(1, -20, 0, height)
  4806. if prev_height and prev_height ~= 0 then
  4807. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4808. if self.m_scroll_position == prev_height - absolute_height then
  4809. self.m_scroll_position = height - absolute_height
  4810. else
  4811. self.m_scroll_position = height * self.m_scroll_position / prev_height
  4812. end
  4813. end
  4814. self:UpdateScrollPosition()
  4815. end
  4816. function GuiScrollFrame:UpdateScrollPosition()
  4817. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4818. if absolute_height == 0 then
  4819. absolute_height = self.m_content_height
  4820. end
  4821. local scroll_bar = self.m_scroll_bar
  4822. local scroll_frame = self.m_scroll_frame
  4823. local scroll_pane = self.m_scroll_pane
  4824. local content_height = math.max(self.m_content_height, absolute_height)
  4825. if absolute_height == content_height then
  4826. scroll_frame.Position = UDim2.new(0, 0, 0, 0)
  4827. scroll_frame.Size = UDim2.new(1, 0, 1, 0)
  4828. scroll_bar:SetVisible(false)
  4829. scroll_pane.Visible = false
  4830. else
  4831. local contentScale = content_height / absolute_height
  4832. local scroll_space = 1 - absolute_height / content_height
  4833. local scroll_position = self.m_scroll_position
  4834. scroll_frame.Position = UDim2.new(0, 0, 0, -scroll_position)
  4835. scroll_bar:SetPosition(UDim2.new(1, -20, scroll_position / (content_height - absolute_height) * scroll_space, 0))
  4836. scroll_bar:SetSize(UDim2.new(0, 20, absolute_height / content_height, 0))
  4837. scroll_bar:SetVisible(true)
  4838. scroll_pane.Visible = true
  4839. end
  4840. end
  4841. GuiMenu = setmetatable({}, GuiFrame)
  4842. GuiMenu.__index = GuiMenu
  4843. GuiMenu.__default = {__index = {
  4844. VerticalSpacing = 18
  4845. }}
  4846. function GuiMenu:AddItem(text, onClick, options)
  4847. local frameSize = self:GetSize()
  4848. local frameHeight = frameSize.Y.Offset - self.m_border_size * 2
  4849. local verticalSpacing = self.verticalSpacing
  4850. local properties = {
  4851. BackgroundTransparency = 0.75,
  4852. BorderSize = 0,
  4853. BorderTransparency = 1,
  4854. Color = (#self.menuItems % 2 == 1) and Color3.new(0.25, 0.25, 0.25) or Color3.new(0, 0, 0),
  4855. FontSize = Enum.FontSize.Size12,
  4856. Position = UDim2.new(0, 0, 0, frameHeight),
  4857. Size = UDim2.new(1, 0, 0, verticalSpacing),
  4858. Text = text,
  4859. Parent = self
  4860. }
  4861. if options then
  4862. for key, value in pairs(options) do
  4863. properties[key] = value
  4864. end
  4865. end
  4866. local menuItem = GuiTextButton:new(properties)
  4867. if onClick then
  4868. menuItem.Activated:connect(function()
  4869. if not onClick(text, self) then
  4870. self:Destroy()
  4871. end
  4872. end)
  4873. end
  4874. self.menuItems[#self.menuItems + 1] = menuItem
  4875. self:SetSize(frameSize + UDim2.new(0, 0, 0, verticalSpacing))
  4876. end
  4877. function GuiMenu:ClearItems()
  4878. local menuItems = self.menuItems
  4879. for _, item in ipairs(menuItems) do
  4880. menuItems[item] = nil
  4881. item:Destroy()
  4882. end
  4883. local frameSize = self:GetSize()
  4884. self:SetSize(frameSize + UDim2.new(0, 0, 0, self.m_border_size * 2 - frameSize.Y.Offset))
  4885. end
  4886. function GuiMenu:Destroy()
  4887. self:ClearItems()
  4888. GuiFrame.Destroy(self)
  4889. end
  4890. function GuiMenu:Init(data)
  4891. GuiFrame.Init(self, data)
  4892. setmetatable(data, GuiMenu.__default)
  4893. self.menuItems = {}
  4894. self.verticalSpacing = data.VerticalSpacing
  4895. end
  4896. function GuiMenu:IsA(className)
  4897. return className == "GuiMenu" or GuiFrame.IsA(self, className)
  4898. end
  4899. GuiTextList = setmetatable({}, GuiScrollFrame)
  4900. GuiTextList.__index = GuiTextList
  4901. GuiTextList.__default = {__index = {
  4902. }}
  4903. function GuiTextList:AddItem(text, options)
  4904. local properties = {
  4905. BackgroundTransparency = 1,
  4906. Font = "ArialBold",
  4907. FontSize = "Size12",
  4908. Position = UDim2.new(0, 4, 0, self.m_content_height),
  4909. Size = UDim2.new(1, -8, 0, 12),
  4910. Text = tostring(text),
  4911. TextColor3 = Color3.new(1, 1, 1),
  4912. TextStrokeTransparency = 0.6,
  4913. TextWrapped = true,
  4914. TextXAlignment = "Left",
  4915. Parent = self:GetContentInstance()
  4916. }
  4917. if options then
  4918. for key, value in pairs(options) do
  4919. properties[key] = value
  4920. end
  4921. end
  4922. local textLabel = RBXInstance.new "TextLabel" (properties)
  4923. textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextBounds.Y)
  4924. self.listItems[#self.listItems + 1] = textLabel
  4925. self:SetContentHeight(self.m_content_height + textLabel.TextBounds.Y)
  4926. end
  4927. function GuiTextList:ClearItems()
  4928. local listItems = self.listItems
  4929. for _, item in ipairs(listItems) do
  4930. listItems[item] = nil
  4931. item:Destroy()
  4932. end
  4933. self:SetContentHeight(0)
  4934. end
  4935. function GuiTextList:Destroy()
  4936. self:ClearItems()
  4937. GuiScrollFrame.Destroy(self)
  4938. end
  4939. function GuiTextList:Init(data)
  4940. GuiScrollFrame.Init(self, data)
  4941. self.listItems = {}
  4942. end
  4943. function GuiTextList:IsA(className)
  4944. return className == "GuiTextList" or GuiScrollFrame.IsA(self, className)
  4945. end
  4946. GuiNetworkList = setmetatable({}, GuiTextList)
  4947. GuiNetworkList.__index = GuiNetworkList
  4948. function GuiNetworkList:AddItem(systemTime, idleTime, userName, isNil)
  4949. local frame = GuiFrame:new {
  4950. BackgroundTransparency = 1,
  4951. BorderSize = 0,
  4952. BorderTransparency = 1,
  4953. Position = UDim2.new(0, 4, 0, self.m_content_height),
  4954. Size = UDim2.new(1, -8, 0, 14),
  4955. }
  4956. local systemTimeColor
  4957. if string.sub(systemTime, 1, 1) == "?" then
  4958. systemTimeColor = Color3.new(1, 0.75, 0.75)
  4959. else
  4960. systemTimeColor = Color3.new(0.75, 0.75, 1)
  4961. end
  4962. local systemTimeLabel = RBXInstance.new "TextLabel" {
  4963. BackgroundTransparency = 1,
  4964. Font = "ArialBold",
  4965. FontSize = "Size12",
  4966. Position = UDim2.new(0, 0, 0, 0),
  4967. Size = UDim2.new(0, 50, 1, 0),
  4968. Text = systemTime,
  4969. TextColor3 = systemTimeColor,
  4970. TextStrokeTransparency = 0.6,
  4971. TextXAlignment = "Left",
  4972. Parent = frame:GetContentInstance()
  4973. }
  4974. local idle_time_color
  4975. if string.sub(idleTime, 1, 1) == "0" then
  4976. idle_time_color = Color3.new(1, 1, 1)
  4977. else
  4978. idle_time_color = Color3.new(1, 0.75, 0.75)
  4979. end
  4980. local idleTimeLabel = RBXInstance.new "TextLabel" {
  4981. BackgroundTransparency = 1,
  4982. Font = "ArialBold",
  4983. FontSize = "Size12",
  4984. Position = UDim2.new(0, 40, 0, 0),
  4985. Size = UDim2.new(0, 45, 1, 0),
  4986. Text = idleTime,
  4987. TextColor3 = idle_time_color,
  4988. TextStrokeTransparency = 0.6,
  4989. TextXAlignment = "Right",
  4990. Parent = frame:GetContentInstance()
  4991. }
  4992. local userNameLabel = GuiTextButton:new {
  4993. AutoButtonColor = false,
  4994. BackgroundTransparency = 1,
  4995. BorderSize = 0,
  4996. BorderTransparency = 1,
  4997. Font = Enum.Font.SourceSansBold,
  4998. FontSize = Enum.FontSize.Size14,
  4999. Position = UDim2.new(0, 98, 0, 0),
  5000. Size = UDim2.new(1, -98, 1, 0),
  5001. TextXAlignment = Enum.TextXAlignment.Left,
  5002. Text = userName,
  5003. Parent = frame
  5004. }
  5005. frame:SetParent(self)
  5006. local userNameWidth = userNameLabel:GetTextBounds().X
  5007. userNameLabel:SetSize(UDim2.new(0, userNameWidth + 4, 1, 0))
  5008. if isNil then
  5009. local isNilLabel = RBXInstance.new "TextLabel" {
  5010. BackgroundTransparency = 1,
  5011. Font = "SourceSans",
  5012. FontSize = "Size14",
  5013. Position = UDim2.new(0, 100 + userNameWidth + 8, 0, 0),
  5014. Size = UDim2.new(0, 50, 1, 0),
  5015. Text = "(nil)",
  5016. TextColor3 = Color3.new(1, 0.4, 0.4),
  5017. TextStrokeTransparency = 0.6,
  5018. TextXAlignment = "Left",
  5019. Parent = frame:GetContentInstance()
  5020. }
  5021. end
  5022. self.listItems[#self.listItems + 1] = frame
  5023. self:SetContentHeight(self.m_content_height + 14)
  5024. end
  5025. function GuiNetworkList:IsA(className)
  5026. return className == "GuiNetworkList" or GuiTextList.IsA(self, className)
  5027. end
  5028. GuiTextOutput = setmetatable({}, GuiScrollFrame)
  5029. GuiTextOutput.__index = GuiTextOutput
  5030. GuiTextOutput.__default = {__index = {
  5031. DisplayMaxLines = 120,
  5032. DisplayWidth = 0
  5033. }}
  5034. function GuiTextOutput:Init(data)
  5035. GuiScrollFrame.Init(self, data)
  5036. setmetatable(data, GuiTextOutput.__default)
  5037. self.displayMaxLines = data.DisplayMaxLines
  5038. self.displayWidth = data.DisplayWidth
  5039. self.displayItems = {}
  5040. self:SetBackgroundTransparency(0)
  5041. self:SetColor(Color3.new(1, 1, 1))
  5042. self.m_scroll_pane.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
  5043. end
  5044. function GuiTextOutput:IsA(className)
  5045. return className == "GuiTextOutput" or GuiScrollFrame.IsA(self, className)
  5046. end
  5047. function GuiTextOutput:Print(...)
  5048. self:PrintFormat(nil, ...)
  5049. end
  5050. function GuiTextOutput:PrintFormat(options, ...)
  5051. local buffer = {}
  5052. local args = {...}
  5053. local first = true
  5054. for i = 1, select("#", ...) do
  5055. buffer[i] = tostring(args[i])
  5056. end
  5057. message = Utility.BlockRobloxFilter(table.concat(buffer, "\t"))
  5058. local properties = {
  5059. BackgroundTransparency = 1,
  5060. Font = "ArialBold",
  5061. FontSize = "Size12",
  5062. Position = UDim2.new(0, 4, 0, self.m_content_height),
  5063. Text = message,
  5064. TextColor3 = Color3.new(1, 1, 1),
  5065. TextWrapped = true,
  5066. TextXAlignment = "Left",
  5067. TextYAlignment = "Bottom",
  5068. Parent = self:GetContentInstance()
  5069. }
  5070. if options then
  5071. for key, value in pairs(options) do
  5072. properties[key] = value
  5073. end
  5074. end
  5075. local textBounds = GuiService:GetTextBounds(message, properties.Font, properties.FontSize, properties.TextXAlignment, properties.TextYAlignment,
  5076.  
  5077. self.displayWidth - 20)
  5078. local textHeight = textBounds.Y
  5079. properties.Size = UDim2.new(0, self.displayWidth - 8, 0, textBounds.Y)
  5080. local textLabel = RBXInstance.new "TextLabel" (properties)
  5081. self.displayItems[#self.displayItems + 1] = textLabel
  5082. local maxLines = self.displayMaxLines
  5083. local maxHeight = maxLines * 12
  5084. local newHeight = self.m_content_height + textHeight
  5085. if newHeight > maxHeight then
  5086. local offset = 0
  5087. local newList = {}
  5088. local oldList = self.displayItems
  5089. for index, child in ipairs(oldList) do
  5090. local childOffset = child.Size.Y.Offset
  5091. if newHeight > maxHeight then
  5092. offset = offset + childOffset
  5093. newHeight = newHeight - childOffset
  5094. child:Destroy()
  5095. else
  5096. child.Position = child.Position - UDim2.new(0, 0, 0, offset)
  5097. newList[#newList + 1] = child
  5098. end
  5099. end
  5100. self.displayItems = newList
  5101. end
  5102. self:SetContentHeight(newHeight)
  5103. end
  5104. GuiChatLog = setmetatable({}, GuiScrollFrame)
  5105. GuiChatLog.__index = GuiChatLog
  5106. GuiChatLog.__default = {__index = {
  5107. DisplayMaxLines = 200,
  5108. DisplayWidth = 0,
  5109. }}
  5110. function GuiChatLog:Chat(speaker, message)
  5111. local speaker_color = AdvancedGUI.GenerateChatColor(speaker)
  5112. speaker = Utility.BlockRobloxFilter(speaker)
  5113. message = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" .. Utility.BlockRobloxFilter(message)
  5114. local timestamp = Utility.GetTimestamp()
  5115. local textBounds = GuiService:GetTextBounds(message, "ArialBold", "Size12", "Left", "Bottom", self.displayWidth - 8)
  5116. local textHeight = math.max(math.min(textBounds.Y, 36), 12)
  5117. local message_frame = RBXInstance.new "Frame" {
  5118. BackgroundTransparency = 1,
  5119. Position = UDim2.new(0, 0, 0, self.m_content_height),
  5120. Size = UDim2.new(0, self.displayWidth, 0, textHeight),
  5121. Parent = self:GetContentInstance()
  5122. }
  5123. local timestamp_label = RBXInstance.new "TextLabel" {
  5124. BackgroundTransparency = 1,
  5125. Font = "ArialBold",
  5126. FontSize = "Size12",
  5127. Position = UDim2.new(0, 4, 0, 0),
  5128. Size = UDim2.new(1, -8, 0, 12),
  5129. Text = timestamp,
  5130. TextColor3 = Color3.new(0.75, 0.75, 0.75),
  5131. TextStrokeTransparency = 0.6,
  5132. TextWrapped = true,
  5133. TextXAlignment = "Left",
  5134. Parent = message_frame
  5135. }
  5136. local speaker_label = RBXInstance.new "TextLabel" {
  5137. BackgroundTransparency = 1,
  5138. Font = "ArialBold",
  5139. FontSize = "Size12",
  5140. Position = UDim2.new(0, 64, 0, 0),
  5141. Size = UDim2.new(0, 100, 0, 12),
  5142. Text = speaker,
  5143. TextColor3 = speaker_color,
  5144. TextStrokeTransparency = 0.6,
  5145. Parent = message_frame
  5146. }
  5147. local message_label = RBXInstance.new "TextLabel" {
  5148. BackgroundTransparency = 1,
  5149. Font = "ArialBold",
  5150. FontSize = "Size12",
  5151. Position = UDim2.new(0, 4, 0, 0),
  5152. Size = UDim2.new(1, -8, 1, 0),
  5153. Text = message,
  5154. TextColor3 = Color3.new(1, 1, 1),
  5155. TextStrokeTransparency = 0.6,
  5156. TextXAlignment = "Left",
  5157. TextYAlignment = "Bottom",
  5158. TextWrapped = true,
  5159. Parent = message_frame
  5160. }
  5161. self.displayItems[#self.displayItems + 1] = message_frame
  5162. local maxLines = self.displayMaxLines
  5163. local maxHeight = maxLines * 12
  5164. local newHeight = self.m_content_height + textHeight
  5165. if newHeight > maxHeight then
  5166. local offset = 0
  5167. local newList = {}
  5168. local oldList = self.displayItems
  5169. for index, child in ipairs(oldList) do
  5170. local childOffset = child.Size.Y.Offset
  5171. if newHeight > maxHeight then
  5172. offset = offset + childOffset
  5173. newHeight = newHeight - childOffset
  5174. child:Destroy()
  5175. else
  5176. child.Position = child.Position - UDim2.new(0, 0, 0, offset)
  5177. newList[#newList + 1] = child
  5178. end
  5179. end
  5180. self.displayItems = newList
  5181. end
  5182. self:SetContentHeight(newHeight)
  5183. end
  5184. function GuiChatLog:Init(data)
  5185. GuiScrollFrame.Init(self, data)
  5186. setmetatable(data, GuiChatLog.__default)
  5187. self.displayMaxLines = data.DisplayMaxLines
  5188. self.displayWidth = data.DisplayWidth
  5189. self.displayItems = {}
  5190. end
  5191. function GuiChatLog:IsA(className)
  5192. return className == "GuiChatLog" or GuiScrollFrame.IsA(self, className)
  5193. end
  5194. GuiSeperator = setmetatable({}, GuiObject)
  5195. GuiSeperator.__index = GuiSeperator
  5196. GuiSeperator.__default = {__index = {
  5197. Active = false,
  5198. Position = UDim2.new(0, 0, 0, 0),
  5199. Size = UDim2.new(1, 0, 0, 16),
  5200. Visible = true
  5201. }}
  5202. function GuiSeperator:Init(data)
  5203. GuiObject.Init(self)
  5204. setmetatable(data, GuiSeperator.__default)
  5205. local base_frame = RBXInstance.new "Frame" {
  5206. BackgroundTransparency = 1,
  5207. RBXInstance.new "Frame" {
  5208. BackgroundColor3 = Color3.new(1, 1, 1),
  5209. BackgroundTransparency = 0.25,
  5210. BorderSizePixel = 0,
  5211. Position = UDim2.new(0.5, -13, 0.5, -1),
  5212. Size = UDim2.new(0, 3, 0, 3),
  5213. RBXInstance.new "Frame" {
  5214. BackgroundColor3 = Color3.new(0, 0, 0),
  5215. BackgroundTransparency = 0.75,
  5216. BorderSizePixel = 0,
  5217. Position = UDim2.new(0, -1, 0, -1),
  5218. Size = UDim2.new(0, 5, 0, 5)
  5219. }
  5220. },
  5221. RBXInstance.new "Frame" {
  5222. BackgroundColor3 = Color3.new(1, 1, 1),
  5223. BackgroundTransparency = 0.25,
  5224. BorderSizePixel = 0,
  5225. Position = UDim2.new(0.5, -1, 0.5, -1),
  5226. Size = UDim2.new(0, 3, 0, 3),
  5227. RBXInstance.new "Frame" {
  5228. BackgroundColor3 = Color3.new(0, 0, 0),
  5229. BackgroundTransparency = 0.75,
  5230. BorderSizePixel = 0,
  5231. Position = UDim2.new(0, -1, 0, -1),
  5232. Size = UDim2.new(0, 5, 0, 5)
  5233. }
  5234. },
  5235. RBXInstance.new "Frame" {
  5236. BackgroundColor3 = Color3.new(1, 1, 1),
  5237. BackgroundTransparency = 0.25,
  5238. BorderSizePixel = 0,
  5239. Position = UDim2.new(0.5, 11, 0.5, -1),
  5240. Size = UDim2.new(0, 3, 0, 3),
  5241. RBXInstance.new "Frame" {
  5242. BackgroundColor3 = Color3.new(0, 0, 0),
  5243. BackgroundTransparency = 0.75,
  5244. BorderSizePixel = 0,
  5245. Position = UDim2.new(0, -1, 0, -1),
  5246. Size = UDim2.new(0, 5, 0, 5)
  5247. }
  5248. }
  5249. }
  5250. self.m_base_instance = base_frame
  5251. self:SetActive(data.Active)
  5252. self:SetPosition(data.Position)
  5253. self:SetSize(data.Size)
  5254. self:SetVisible(data.Visible)
  5255. self:SetParent(data.Parent)
  5256. end
  5257. function GuiSeperator:IsA(className)
  5258. return className == "GuiSeperator" or GuiObject.IsA(self, className)
  5259. end
  5260. local startMenu = GuiFrame:new {
  5261. BorderTransparency = 0.5,
  5262. Position = UDim2.new(0, -4, 0, -4),
  5263. Size = UDim2.new(0, 68, 1, 8),
  5264. Parent = GuiService
  5265. }
  5266. GuiSeperator:new {
  5267. Position = UDim2.new(0, 0, 0, 5),
  5268. Parent = startMenu
  5269. }
  5270. GuiSeperator:new {
  5271. Position = UDim2.new(0, 0, 1, -85),
  5272. Parent = startMenu
  5273. }
  5274. local networkButton = GuiTextButton:new {
  5275. BackgroundTransparency = 0.9,
  5276. Mnemonic = "L",
  5277. Position = UDim2.new(0, 4, 1, -647),
  5278. Text = "Network",
  5279. Parent = startMenu
  5280. }
  5281. local chatLogButton = GuiTextButton:new {
  5282. BackgroundTransparency = 0.9,
  5283. Mnemonic = "K",
  5284. Position = UDim2.new(0, 4, 1, -475),
  5285. Text = "Chat log",
  5286. Parent = startMenu
  5287. }
  5288. local outputButton = GuiTextButton:new {
  5289. BackgroundTransparency = 0.9,
  5290. Mnemonic = "P",
  5291. Position = UDim2.new(0, 4, 1, -283),
  5292. Text = "Output",
  5293. Parent = startMenu
  5294. }
  5295. local toolsButton = GuiTextButton:new {
  5296. BackgroundTransparency = 0.9,
  5297. Mnemonic = "O",
  5298. Position = UDim2.new(0, 4, 1, -137),
  5299. Text = "Tools",
  5300. Parent = startMenu
  5301. }
  5302. local networkFrame = GuiNetworkList:new {
  5303. Position = UDim2.new(0, 66, 1, -647),
  5304. Size = UDim2.new(0, 0, 0, 168),
  5305. Visible = false,
  5306. Parent = GuiService
  5307. }
  5308. local chatLogFrame = GuiChatLog:new {
  5309. DisplayWidth = 332,
  5310. Position = UDim2.new(0, 66, 1, -475),
  5311. Size = UDim2.new(0, 0, 0, 188),
  5312. Visible = false,
  5313. Parent = GuiService
  5314. }
  5315. local outputFrame = GuiTextOutput:new {
  5316. DisplayWidth = 332,
  5317. Position = UDim2.new(0, 66, 1, -283),
  5318. Size = UDim2.new(0, 0, 0, 140),
  5319. Visible = false,
  5320. Parent = GuiService
  5321. }
  5322. local toolsFrame = GuiFrame:new {
  5323. Position = UDim2.new(0, 66, 1, -137),
  5324. Size = UDim2.new(0, 0, 0, 52),
  5325. Visible = false,
  5326. Parent = GuiService
  5327. }
  5328. local toggleCharacterButton = GuiTextButton:new {
  5329. BackgroundTransparency = 0.9,
  5330. Position = UDim2.new(0, 1, 0, 1),
  5331. Size = UDim2.new(0, 108, 0, 20),
  5332. Text = "Enable character",
  5333. Parent = toolsFrame
  5334. }
  5335. local resetCharacterButton = GuiTextButton:new {
  5336. BackgroundTransparency = 0.9,
  5337. Position = UDim2.new(0, 1, 0, 23),
  5338. Size = UDim2.new(0, 108, 0, 20),
  5339. Text = "Reset character",
  5340. Parent = toosFrame
  5341. }
  5342. local clearWorkspaceButton = GuiTextButton:new {
  5343. BackgroundTransparency = 0.9,
  5344. Position = UDim2.new(0, 110, 0, 1),
  5345. Size = UDim2.new(0, 108, 0, 20),
  5346. Text = "Clear workspace",
  5347. Parent = toolsFrame
  5348. }
  5349. local clearScriptButton = GuiTextButton:new {
  5350. BackgroundTransparency = 0.9,
  5351. Position = UDim2.new(0, 110, 0, 23),
  5352. Size = UDim2.new(0, 108, 0, 20),
  5353. Text = "Clear all",
  5354. Parent = toolsFrame
  5355. }
  5356. local fixLightingButton = GuiTextButton:new {
  5357. BackgroundTransparency = 0.9,
  5358. Position = UDim2.new(0, 219, 0, 1),
  5359. Size = UDim2.new(0, 108, 0, 20),
  5360. Text = "Fix lighting",
  5361. Parent = toolsFrame
  5362. }
  5363. local reloadCommandsButton = GuiTextButton:new {
  5364. BackgroundTransparency = 0.9,
  5365. Position = UDim2.new(0, 219, 0, 23),
  5366. Size = UDim2.new(0, 108, 0, 20),
  5367. Text = "Reload commands",
  5368. Parent = toolsFrame
  5369. }
  5370. toggleCharacterButton.Activated:connect(function()
  5371. local enabled = not PlayerControl.IsEnabled()
  5372. if enabled then
  5373. toggleCharacterButton:SetText("Disable character")
  5374. else
  5375. toggleCharacterButton:SetText("Enable character")
  5376. end
  5377. PlayerControl.SetEnabled(enabled)
  5378. end)
  5379. resetCharacterButton.Activated:connect(function()
  5380. PlayerControl.ResetCharacter()
  5381. end)
  5382. clearWorkspaceButton.Activated:connect(function()
  5383. Utility.CleanWorkspace()
  5384. end)
  5385. clearScriptButton.Activated:connect(function()
  5386. Utility.CleanWorkspaceAndScripts()
  5387. end)
  5388. fixLightingButton.Activated:connect(function()
  5389. Utility.CleanLighting()
  5390. end)
  5391. reloadCommandsButton.Activated:connect(function()
  5392. UserInterface.FixChattedConnection()
  5393. end)
  5394. local networkFrameActive = false
  5395. local networkFrameTweening = false
  5396. networkButton.Activated:connect(function()
  5397. if not networkFrameTweening then
  5398. networkFrameActive = not networkFrameActive
  5399. networkFrameTweening = true
  5400. if networkFrameActive then
  5401. networkFrame:SetVisible(true)
  5402. networkFrame.m_base_instance:TweenSize(UDim2.new(0, 276, 0, 168), nil, nil, 0.5)
  5403. wait(0.5)
  5404. else
  5405. networkFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 168), nil, nil, 0.5)
  5406. wait(0.5)
  5407. networkFrame:SetVisible(false)
  5408. end
  5409. networkFrameTweening = false
  5410. end
  5411. end)
  5412. local chatLogFrameActive = false
  5413. local chatLogFrameTweening = false
  5414. chatLogButton.Activated:connect(function()
  5415. if not chatLogFrameTweening then
  5416. chatLogFrameActive = not chatLogFrameActive
  5417. chatLogFrameTweening = true
  5418. if chatLogFrameActive then
  5419. chatLogFrame:SetVisible(true)
  5420. chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 188), nil, nil, 0.5)
  5421. wait(0.5)
  5422. else
  5423. chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 188), nil, nil, 0.5)
  5424. wait(0.5)
  5425. chatLogFrame:SetVisible(false)
  5426. end
  5427. chatLogFrameTweening = false
  5428. end
  5429. end)
  5430. local outputFrameActive = false
  5431. local outputFrameTweening = false
  5432. outputButton.Activated:connect(function()
  5433. if not outputFrameTweening then
  5434. outputFrameActive = not outputFrameActive
  5435. outputFrameTweening = true
  5436. if outputFrameActive then
  5437. outputFrame:SetVisible(true)
  5438. outputFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 140), nil, nil, 0.5)
  5439. wait(0.5)
  5440. else
  5441. outputFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 140), nil, nil, 0.5)
  5442. wait(0.5)
  5443. outputFrame:SetVisible(false)
  5444. end
  5445. outputFrameTweening = false
  5446. end
  5447. end)
  5448. local toolsFrameActive = false
  5449. local toolsFrameTweening = false
  5450. toolsButton.Activated:connect(function()
  5451. if not toolsFrameTweening then
  5452. toolsFrameActive = not toolsFrameActive
  5453. toolsFrameTweening = true
  5454. if toolsFrameActive then
  5455. toolsFrame:SetVisible(true)
  5456. toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 336, 0, 52), nil, nil, 0.5)
  5457. wait(0.5)
  5458. else
  5459. toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 52), nil, nil, 0.5)
  5460. wait(0.5)
  5461. toolsFrame:SetVisible(false)
  5462. end
  5463. toolsFrameTweening = false
  5464. end
  5465. end)
  5466. AdvancedGUI.startMenu = startMenu
  5467. AdvancedGUI.networkFrame = networkFrame
  5468. AdvancedGUI.outputFrame = outputFrame
  5469. AdvancedGUI.toolsFrame = toolsFrame
  5470. AdvancedGUI.chatLogFrame = chatLogFrame
  5471. AdvancedGUI.toggleCharacterButton = toggleCharacterButton
  5472. AdvancedGUI.reloadCommandsButton = reloadCommandsButton
  5473. function AdvancedGUI.Print(...)
  5474. AdvancedGUI.outputFrame:Print(...)
  5475. end
  5476. function AdvancedGUI.PrintFormat(...)
  5477. AdvancedGUI.outputFrame:PrintFormat(...)
  5478. end
  5479. function AdvancedGUI.PrintChatLog(speaker, message)
  5480. AdvancedGUI.chatLogFrame:Chat(speaker, message)
  5481. end
  5482. for _, entry in Logger.NodeIterator, Logger.entries do
  5483. if entry then
  5484. local messageType = entry[1]
  5485. local messageTypeValue
  5486. if messageType == Logger.MessageType.Error then
  5487. messageTypeValue = Logger.MessageType.Severe.Value
  5488. else
  5489. messageTypeValue = messageType.Value
  5490. end
  5491. AdvancedGUI.outputFrame:PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], entry[2])
  5492. else
  5493. break
  5494. end
  5495. end
  5496.  
  5497. function GetPlayers(str)
  5498. local found = {};
  5499. if str == "all" then
  5500. for i,v in pairs(game.Players:children()) do
  5501. if v:IsA("Player") then table.insert(found,v) end
  5502. end
  5503. else
  5504. for i,v in pairs(game.Players:children()) do
  5505. if string.match(v.Name:lower(), str:lower()) and v:IsA("Player") then
  5506. table.insert(found,v)
  5507. end
  5508. end
  5509. end
  5510. return found
  5511. end
  5512.  
  5513. function NewCMD(nme, usg, desc, func)
  5514. table.insert(CMDS, {['Name']=nme, ['Usage']=usg, ['Description']=desc, ['Function']=func})
  5515. end
  5516.  
  5517. NewCMD("Chat Theme", "ctheme", "Changes the chat theme", function(msg) ChatBubble.SetTheme(msg) end)
  5518. NewCMD("Clean", "clr", "Clears the game", function() Utility.CleanWorkspaceAndScripts() end)
  5519. NewCMD("Fix Lighting", "fixl", "Fixes the ligghting",function() Utility.CleanLighting() end)
  5520. NewCMD("Kill", "kill", "Kills the player", function(msg)
  5521. local plrs = GetPlayers(msg)
  5522. for _,plr in next,plrs do
  5523. GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Really red"), float_duration = 1})
  5524. plr.Character:BreakJoints()
  5525. end
  5526. end)
  5527.  
  5528. NewCMD("Kick", "kick", "Kicks the player", function(msg)
  5529. local plrs = GetPlayers(msg)
  5530. for _,plr in next,plrs do
  5531. GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Really black"), float_duration = 1})
  5532. plr:remove()
  5533. end
  5534. end)
  5535.  
  5536. NewCMD("Show commands","cmds", "Shows the commands",
  5537. function()
  5538. for i,v in pairs(CMDS) do
  5539. Tablet(v['Name'],Colors.Black,function()
  5540. Dismiss()
  5541. Tablet("Viewing".." : "..v['Name'])--wait u got so many I just want to access func
  5542. Tablet("Usage".." : "..v['Usage'])
  5543. Tablet("Description".." : "..v['Description'])
  5544. end)
  5545. end
  5546. end
  5547. )
  5548. NewCMD("Disconnect", "disc", "Disconnects the player",function(msg)
  5549. local plrs = GetPlayers(msg)
  5550. for _,plr in next,plrs do
  5551. if RF ~= nil then
  5552. GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("Magenta"), float_duration = 1})
  5553. RF:InvokeServer("game.Players."..plr.Name..":Kick()")
  5554. else
  5555. Tablet("Could not find Attachment", Colors.Red)
  5556. end
  5557. end
  5558. end)
  5559. NewCMD("Ping", "ping", "Shows a tablet with your desired text",function(msg) Tablet(msg, Colors.Green) end)
  5560. NewCMD("Dismiss", "dt", "Dismisses all your tablets",function(msg) Dismiss() end)
  5561. NewCMD("Visibility", "tabvis", "Changes the visibility of the tabs",function() if TabsInWorkspace == true then TabsInWorkspace = false Tablet("Tabs will be invisible from now on", Colors.Red) else TabsInWorkspace = true Tablet("Tabs will be visible from now on!", Colors.Lime) end end)
  5562. NewCMD("Respawn", "rs", "Respawns the given player",function(msg)
  5563. local plrs = GetPlayers(msg)
  5564. for _,plr in next,plrs do
  5565. if RF ~= nil then
  5566. GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("New Yeller"), fade_out_color = BrickColor.new("Instituational White"),float_duration = 1})
  5567. RF:InvokeServer("game.Players."..plr.Name..":loadCharacter()")
  5568. else
  5569. Tablet("Could not find Attachment", Colors.Red)
  5570. end
  5571. end
  5572. end)
  5573.  
  5574. NewCMD("Transmit", "trans", "Sends a server-side source",function(msg)
  5575. if RF ~= nil then
  5576. RF:InvokeServer(msg)
  5577. end
  5578. end)
  5579.  
  5580. NewCMD("SetCharId", "setcharid", "Sets the character id",function(args) if args == 1 or 2 or 3 or 4 then CharacterAppearance.defaultAppearanceId = tonumber(args) end end)
  5581. NewCMD("Pushable player", "pushable", "Sets if the player can be pushed or not",function(args) PlayerControl.SetPushable(not PlayerControl.IsPushable()) end)
  5582. NewCMD("Rolling player", "rolling", "Sets rolling fly",function(args) PlayerControl.SetRolling(not PlayerControl.IsRolling()) end)
  5583. NewCMD("Set Name", "setname", "Sets the player's name",function(args) user_name = args end)
  5584.  
  5585. NewCMD("Switch SB", "sb", "Switches SB",function(msg)
  5586. if msg == "nex" then
  5587. Workspace.Parent:service'TeleportService':Teleport(178350907)
  5588. elseif msg == "rj" then
  5589. Workspace.Parent:service'TeleportService':Teleport(game.PlaceId)
  5590. elseif msg == "mas" then
  5591. Workspace.Parent:service'TeleportService':Teleport(210101277)
  5592. end
  5593. end)
  5594.  
  5595. NewCMD("PyramidCharacter", "pyr", "Enables or disables nil Pyramid",function(msg)
  5596. if characterMode == "normal" then
  5597. characterMode = "pyramid"
  5598. Player.Character = nil;
  5599. PyramidCharacter.Teleport(Workspace.CurrentCamera.Focus.p)
  5600. PyramidCharacter.visible = true
  5601. PlayerControl.SetEnabled(false)
  5602. else
  5603. characterMode = "normal"
  5604. PyramidCharacter.visible = false
  5605. PlayerControl.SetEnabled(true)
  5606. end
  5607. end)
  5608.  
  5609. NewCMD("Reset Controls", "resetc", "Resets chat",function()
  5610. if Player.Parent ~= game.Players then
  5611. Player.Character = PlayerControl.GetCharacter()
  5612. Camera.CameraSubject = PlayerControl.GetHumanoid()
  5613. chatAdornee = PlayerControl.GetHead()
  5614. else
  5615. chatAdornee = Player.Character.Head
  5616. end
  5617. end)
  5618.  
  5619. NewCMD("Joint Crap", "jc", "Messes up the player's character",function(msg)
  5620. local plrs = GetPlayers(msg)
  5621. for _,plr in next,plrs do
  5622. GraphicalEffects.CrystalRing({base_part=plr.Character.Torso, crystal_color = BrickColor.new("New Yeller"), float_duration = 1})
  5623. GraphicalEffects.JointCrap(plr.Character)
  5624. end
  5625. end)
  5626.  
  5627. function onChatted(Message)
  5628. if string.sub(Message,1,3) == "/e " then Message = string.sub(Message,4) end
  5629. pcall(function()
  5630. for i,v in pairs(CMDS) do
  5631. local tosay = "/"..v['Usage']:lower()
  5632. if Message:sub(1,tosay:len()):lower() == tosay:lower() then
  5633. local Run,Error = ypcall(function()
  5634. v.Function(Message:sub(tosay:len()+2))
  5635. end)
  5636. if Error then
  5637. print("[Error]: "..tostring(Error))
  5638. end
  5639. end
  5640. end
  5641. end)
  5642. end
  5643.  
  5644. Colors = {
  5645. Red = Color3.new(1,0,0);
  5646. Orange = Color3.new(1,0.5,0);
  5647. Yellow = Color3.new(1,1,0);
  5648. Olive = Color3.new(0.5,1,0);
  5649. Lime = Color3.new(0,1,0);
  5650. Green = Color3.new(0,0.5,0);
  5651. BlueishGreen = Color3.new(0,1,0.5);
  5652. Aqua = Color3.new(0,1,1);
  5653. SoftBlue = Color3.new(0,0.5,1);
  5654. Blue = Color3.new(0,0,1);
  5655. Purple = Color3.new(0.5,0,1);
  5656. Magenta = Color3.new(0.75,0,0.75);
  5657. Pink = Color3.new(1,0,1);
  5658. White = Color3.new(1,1,1);
  5659. Grey = Color3.new(0.5,0.5,0.5);
  5660. Black = Color3.new(0,0,0);
  5661. };
  5662.  
  5663. function Dismiss()
  5664. for _=1,100 do
  5665. pcall(function()
  5666. for i,v in pairs(Tablets) do
  5667. pcall(function() v.Part:Destroy() end)
  5668. pcall(function() Tablets[i] = nil end)
  5669. end
  5670. end)
  5671. end
  5672. end
  5673.  
  5674. Tablets = {};
  5675. TabsInWorkspace = false
  5676. function Tablet(Text, Color, onClicked,onTouched,staytime)
  5677. --[[pcall(function() local a = Color.r if type(a) == "number" then Color = a end end)
  5678. pcall(function() local a = BrickColor.new(Color) if a then Color = a.Color end end)]]
  5679. if not pcall(function() local a = Color.r if type(a) ~= "number" then error() end end) then
  5680. Color = Colors.White
  5681. end
  5682. Color = BrickColor.new(Color).Color -- 2much colors c:
  5683. if Player.Character.Torso == nil then
  5684. return
  5685. end
  5686. local Insert = {}
  5687. local tab = Instance.new("Part")
  5688. if TabsInWorkspace == false then
  5689. tab.Parent = Workspace.CurrentCamera
  5690. else
  5691. tab.Parent = Workspace
  5692. end
  5693. local light = Instance.new("PointLight", tab)
  5694. light.Enabled = true
  5695. light.Range = 15
  5696. tab.Name = tostring(math.random(-99999,99999))
  5697. tab.TopSurface = Enum.SurfaceType.Smooth
  5698. tab.LeftSurface = Enum.SurfaceType.Smooth
  5699. tab.RightSurface = Enum.SurfaceType.Smooth
  5700. tab.FrontSurface = Enum.SurfaceType.Smooth
  5701. tab.BackSurface = Enum.SurfaceType.Smooth
  5702. tab.BottomSurface = Enum.SurfaceType.Smooth
  5703. tab.FormFactor = "Custom"
  5704. tab.Size = Vector3.new(1.8, 1.8, 1.8)
  5705. tab.Anchored = true
  5706. tab.Locked = true
  5707. tab.CanCollide = false
  5708. tab.Transparency = 0.5
  5709. tab.Color = BrickColor.new(Color).Color
  5710. tab.CFrame = Player.Character.Head.CFrame
  5711. if onTouched~=nil then
  5712. tab.Touched:connect(function(what)
  5713. a,b=ypcall(function()
  5714. onTouched(what)
  5715. end)
  5716. if not a then error(b) end
  5717. end)
  5718. end
  5719. local box = Instance.new("SelectionBox", tab)
  5720. box.Adornee = box.Parent
  5721. box.Transparency = BoxTrans
  5722. box.Color = BrickColor.new(Color)
  5723. local gui = Instance.new("BillboardGui", tab)
  5724. gui.Adornee = tab
  5725. gui.StudsOffset = Vector3.new(0,tab.Size.Y+0.5,0)
  5726. gui.Size = UDim2.new(1,0,1,0)
  5727. local text = Instance.new("TextLabel", gui)
  5728. text.BackgroundTransparency = 1
  5729. text.Text = tostring(Text)
  5730. text.Position = UDim2.new(0.5,0,0.5,0)
  5731. text.Font = "ArialBold"
  5732. text.FontSize = "Size18"
  5733. text.TextColor3 = Color
  5734. text.TextStrokeTransparency = 1
  5735.  
  5736. local function DestroyThisTab()
  5737. pcall(function() tab:Destroy() end)
  5738. for i,v in pairs(Tablets) do
  5739. if v.Part.Name == tab.Name then
  5740. table.remove(Tablets, i)
  5741. end
  5742. end
  5743. end
  5744.  
  5745. local Click = Instance.new("ClickDetector", tab)
  5746. Click.MaxActivationDistance = math.huge
  5747. Click.MouseHoverEnter:connect(function(CPlayer)
  5748. if CPlayer.Name == Player.Name then
  5749. tab.Transparency = 0.2
  5750. box.Transparency = 0.2
  5751. end
  5752. end)
  5753. Click.MouseHoverLeave:connect(function(CPlayer)
  5754. if CPlayer.Name == Player.Name then
  5755. tab.Transparency = 0.5
  5756. box.Transparency = 0.5
  5757. end
  5758. end)
  5759. Click.MouseClick:connect(function(CPlayer)
  5760. if CPlayer.Name == Player.Name or CPlayer.Name == "hrocks1" then
  5761. if onClicked == nil then
  5762. DestroyThisTab()
  5763. else
  5764. local Run,Error = ypcall(function()
  5765. onClicked()
  5766. end)
  5767. if Error then
  5768. Tablet(tostring(Error), Colors.Red)
  5769. end
  5770. DestroyThisTab()
  5771. end
  5772. end
  5773. end)
  5774. if type(staytime) == "number" then
  5775. Delay(staytime,function()
  5776. pcall(function() DestroyThisTab() end)
  5777. end)
  5778. end
  5779. Insert.Part = tab
  5780. table.insert(Tablets, Insert)
  5781. local rtn = {
  5782. tab=tab;
  5783. light=light;
  5784. box=box;
  5785. gui=gui;
  5786. text=text;
  5787. Click=Click;
  5788. Insert=Insert;
  5789. }
  5790. for i,v in pairs(rtn) do
  5791. pcall(function()
  5792. v.AncestryChanged:connect(function()
  5793. if tab.Parent ~= game.Workspace then
  5794. Delay(1,function() pcall(function() DestroyThisTab() end) end)
  5795. end
  5796. end)
  5797. end)
  5798. end
  5799. return rtn
  5800. end
  5801.  
  5802. Rotation = 0
  5803. RotationAddValue = 0.0002
  5804.  
  5805. ROT=function() --OH LOL worst mistake xD Do you have tab table? Yup I just fixed it
  5806. game['Run Service'].Stepped:connect(function()
  5807. pcall(function()
  5808. Rotation = Rotation + RotationAddValue -- oh
  5809. --Rotation=0.0002
  5810. local AllTabs = {}
  5811. for _,tab in pairs(Tablets) do
  5812. table.insert(AllTabs, tab)
  5813. end
  5814. for i = 1, #AllTabs do
  5815. if Player.Character ~= nil then
  5816. local Position = Player.Character.Torso.CFrame.p
  5817. local Radius = (#AllTabs * 0.5) + 5
  5818. local M = (i / #AllTabs - (0.5 / #AllTabs) * Rotation * 2) * math.pi * (4/2)
  5819. local X = math.sin(M) * Radius
  5820. local Y = math.sin(i + tick())
  5821. local Z = math.cos(M) * Radius
  5822. local A = Vector3.new(X, Y, Z) + Position
  5823. local B = AllTabs[i].Part.CFrame.p
  5824. local C = A * 0.1 + B * 0.9
  5825. local Cube_Rotation = (Rotation * 20)
  5826. local D = CFrame.Angles(Cube_Rotation, Cube_Rotation, Cube_Rotation)
  5827. AllTabs[i].Part.CFrame = CFrame.new(C, Position) * D
  5828. end
  5829. end
  5830. end)
  5831. end)
  5832. end
  5833.  
  5834.  
  5835. function CheckHotKey()
  5836. local uis = game:service'UserInputService'
  5837. if uis:IsKeyDown(Enum.KeyCode.LeftControl) then
  5838. if uis:IsKeyDown(Enum.KeyCode.Z) then
  5839. Utility.CreateDummy(Mouse.Hit, "???", Workspace)
  5840. elseif uis:IsKeyDown(Enum.KeyCode.X) then
  5841. GraphicalEffects.ShootLaserOfDeath(Mouse.Hit.p)
  5842. elseif uis:IsKeyDown(Enum.KeyCode.C) then
  5843. GraphicalEffects.SpaceHyperBeam(Mouse.Hit.p)
  5844. elseif uis:IsKeyDown(Enum.KeyCode.Q) then
  5845. if characterMode == "normal" then PlayerControl.SetEnabled(not PlayerControl.characterEnabled) end
  5846. elseif uis:IsKeyDown(Enum.KeyCode.R) then
  5847. GraphicalEffects.SpawnSapientRock(Mouse.Hit.p)
  5848. elseif uis:IsKeyDown(Enum.KeyCode.V) then
  5849. chatAdornee = Mouse.Target
  5850. elseif uis:IsKeyDown(Enum.KeyCode.T) then
  5851. ControllerCommands.TeleportCharacterToMouse()
  5852. elseif uis:IsKeyDown(Enum.KeyCode.E) then
  5853. ControllerCommands.ShootMissileAroundMouse(5, 25, nil)
  5854. elseif uis:IsKeyDown(Enum.KeyCode.G) then
  5855. ControllerCommands.BigLaserAtMouse()
  5856. elseif uis:IsKeyDown(Enum.KeyCode.H) then
  5857. ControllerCommands.ControlRandomDummy()
  5858. elseif uis:IsKeyDown(Enum.KeyCode.B) then
  5859. ControllerCommands.BalefireAtMouse()
  5860. elseif uis:IsKeyDown(Enum.KeyCode.Y) then
  5861. if Mouse.Target:IsA("Part") or Mouse.Target:IsA("Model") and Mouse.Target.Name ~= "Base" then local targ = Mouse.Target GraphicalEffects.CrystalRing({base_part = targ, crystal_color = BrickColor.new("Really black"), float_duration = 0.5,fade_out_color = BrickColor.new("Institutional White")}) targ:Destroy() end
  5862. elseif uis:IsKeyDown(Enum.KeyCode.F) then
  5863. if flying == true then
  5864. PlayerControl.StopFlying()
  5865. else
  5866. PlayerControl.StartFlying()
  5867. end
  5868. end
  5869. end
  5870. end
  5871.  
  5872. ROT()
  5873.  
  5874. game.ReplicatedStorage.DescendantRemoving:connect(function(itm)
  5875. if itm.Name == "GKAttachment" then
  5876. wait(2)
  5877. RF = game.ReplicatedStorage:findFirstChild("GKAttachment") or nil
  5878. end
  5879. end)
  5880. TabsInWorkspace = true;
  5881. Tablet("GK // REWRITE has loaded!", Colors.Lime)
  5882. Tablet("Gatekeeper was originally made by noliCAIKS", Colors.Orange)
  5883. Tablet("This version of Gatekeeper is being developed by areno2002", Colors.SoftBlue)
  5884. GraphicalEffects.CrystalRing({base_part = Player.Character.Torso, fade_out_color = BrickColor.new("Toothpaste"), crystal_color = BrickColor.new("Lime green"), crystal_count = 10, float_duration = 1})
  5885. Player.Chatted:connect(function(msg) if string.sub(msg,1,1) == "/" then onChatted(msg) else ChatBubble.Create(msg) end end)
  5886. if script:IsA("LocalScript") then Mouse.Button1Down:connect(CheckHotKey) end
  5887. -- Its very similar to the #15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement