Advertisement
Vegasxxkillingx

Untitled

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