Advertisement
U_M9

GateKeeper [LocalScript]

Dec 31st, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 145.78 KB | None | 0 0
  1. wait()
  2. script:Destroy()
  3.  
  4. local shared = shared
  5. local _G = _G
  6. local coroutine = coroutine
  7. local string = string
  8. local table = table
  9. local os = os
  10. local next = next
  11. local tonumber = tonumber
  12. local tostring = tostring
  13. local getfenv = getfenv
  14. local getmetatable = getmetatable
  15. local unpack = unpack
  16. local setmetatable = setmetatable
  17. local ypcall = ypcall
  18. local xpcall = xpcall
  19. local pairs = pairs
  20. local rawget = rawget
  21. local newproxy = newproxy
  22. local collectgarbage = collectgarbage
  23. local rawset = rawset
  24. local ipairs = ipairs
  25. local type = type
  26. local gcinfo = gcinfo
  27. local rawequal = rawequal
  28. local select = select
  29. local print = print
  30. local pcall = pcall
  31. local assert = assert
  32. local loadstring = loadstring
  33. local setfenv = setfenv
  34. local error = error
  35. local delay = delay
  36. local spawn = spawn
  37. local game = game
  38. local workspace = workspace
  39. local Instance = Instance
  40. local Color3 = Color3
  41. local BrickColor = BrickColor
  42. local Vector3 = Vector3
  43. local UDim2 = UDim2
  44. local Enum = Enum
  45. local wait = wait
  46. local currentTime = 0
  47. local rbx_coroutine_create = coroutine.create
  48. local rbx_coroutine_resume = coroutine.resume
  49. local rbx_Wait = wait
  50. local rbx_ypcall = ypcall
  51. local chatAdornee
  52.  
  53. local threads, swapThreads = {}, {}
  54. local function StartCoroutine(func, delay, ...)
  55.     if delay > 0 then
  56.         rbx_Wait(delay)
  57.     end
  58.     local success, message = rbx_ypcall(func, ...)
  59.     if not success then
  60.     end
  61. end
  62.  
  63. local function IsBrickColor(object)
  64.     local _ = object.Color
  65. end
  66. local function IsCFrame(object)
  67.     local _ = object.p
  68. end
  69. local function IsColor3(object)
  70.     local _ = object.r
  71. end
  72. local function IsCustom(object)
  73.     return object._6kSo06Sum0aZ7HK
  74. end
  75. local function IsInstance(object)
  76.     local _ = object.IsA
  77. end
  78. local function IsRay(object)
  79.     local _ = object.Origin
  80. end
  81. local function IsVector2(object)
  82.     local _ = object.Z
  83. end
  84. local function IsVector3(object)
  85.     local _ = object.Z
  86. end
  87. local function IsUDim(object)
  88.     local _ = object.Scale
  89. end
  90. local function IsUDim2(object)
  91.     IsUDim(object.Y)
  92. end
  93. local function Color3ToString(color)
  94.     return string.format("{r = %.6g, g = %.6g, b = %.6g}", color.r, color.g, color.b)
  95. end
  96. local function Vector3ToString(vector)
  97.     return string.format("{X = %.7g, Y = %.7g, Z = %.7g}", vector.X, vector.Y, vector.Z)
  98. end
  99. local function UDimToString(udim)
  100.     return string.format("{Scale = %.9g, Offset = %i}", udim.Scale, udim.Offset)
  101. end
  102.  
  103. local math = {
  104.     abs = math.abs,
  105.     acos = math.acos,
  106.     asin = math.asin,
  107.     atan = math.atan,
  108.     atan2 = math.atan2,
  109.     ceil = math.ceil,
  110.     cos = math.cos,
  111.     cosh = math.cosh,
  112.     deg = math.deg,
  113.     exp = math.exp,
  114.     floor = math.floor,
  115.     fmod = math.fmod,
  116.     frexp = math.frexp,
  117.     huge = math.huge,
  118.     ldexp = math.ldexp,
  119.     log = math.log,
  120.     log10 = math.log10,
  121.     max = math.max,
  122.     min = math.min,
  123.     modf = math.modf,
  124.     phi = 1.618033988749895,
  125.     pi = math.pi,
  126.     pow = math.pow,
  127.     rad = math.rad,
  128.     random = math.random,
  129.     randomseed = math.randomseed,
  130.     sin = math.sin,
  131.     sinh = math.sinh,
  132.     sqrt = math.sqrt,
  133.     tan = math.tan,
  134.     tanh = math.tanh,
  135.     tau = 2 * math.pi
  136. };
  137.  
  138. local Players = game:GetService("Players");
  139. local RunService = game:service'RunService';
  140. local LogService = game:service'LogService';
  141. local InsertService = game:service'InsertService';
  142. local Player = Players.LocalPlayer
  143. local Mouse = Player:GetMouse()
  144. local UserInterface = game:service'UserInputService'
  145. local Camera = workspace.CurrentCamera
  146.  
  147. local GetPlayers=function(msg)
  148.     local found = {};
  149.     for _,plr in pairs(Players:GetPlayers()) do
  150.         if string.match(plr.Name, msg) then
  151.             table.insert(found, plr)
  152.         end
  153.     end
  154.     return found
  155. end
  156.  
  157. local stock_triangle = Instance.new("WedgePart")
  158. stock_triangle.Anchored = true
  159. stock_triangle.BottomSurface = "Smooth"
  160. stock_triangle.FormFactor = "Custom"
  161. stock_triangle.Locked = true
  162. stock_triangle.TopSurface = "Smooth"
  163. local stock_triangle_mesh = Instance.new("SpecialMesh", stock_triangle)
  164. stock_triangle_mesh.MeshType = "Wedge"
  165. local triangles = {}
  166.  
  167. local Utility = {};
  168. function Utility.BlockRobloxFilter(text)
  169.     return string.gsub(text, ".", "%1\143")
  170. end
  171.  
  172. function Utility.GetRobloxType(value)
  173.     local luaType = type(value)
  174.     if luaType == "boolean" then
  175.         return "Bool"
  176.     elseif luaType == "nil" then
  177.         return "Object"
  178.     elseif luaType == "number" then
  179.         return "Number"
  180.     elseif luaType == "string" then
  181.         return "String"
  182.     elseif luaType == "userdata" then
  183.         if pcall(IsInstance, value) then
  184.             return "Object"
  185.         elseif pcall(IsRay, value) then
  186.             return "Ray"
  187.         elseif pcall(IsCFrame, value) then
  188.             return "CFrame"
  189.         elseif pcall(IsVector3, value) then
  190.             return "Vector3"
  191.         elseif pcall(IsBrickColor, value) then
  192.             return "BrickColor"
  193.         elseif pcall(IsColor3, value) then
  194.             return "Color3"
  195.         end
  196.     end
  197. end
  198. function Utility.ToString(value)
  199.     local luaType = type(value)
  200.     if luaType == "string" then
  201.         return string.format("%q", value)
  202.     elseif luaType == "table" then
  203.         local metatable = getmetatable(value)
  204.         if type(metatable) == "table" then
  205.             local success, metatableName = pcall(tostring, metatable)
  206.             if not success then
  207.                 metatableName = "(bad __tostring)"
  208.             end
  209.             local valueName
  210.             success, valueName = pcall(tostring, value)
  211.             if not success then
  212.                 valueName = "(bad __tostring)"
  213.             end
  214.             return string.format("{...(%s/metatable=%s)}", valueName, metatableName)
  215.         elseif metatable ~= nil then
  216.             return string.format("{...(%s/metatable=%s)}", tostring(value), Utility.ToString(metatable))
  217.         else
  218.             return string.format("{...(%s)}", tostring(value))
  219.         end
  220.     elseif luaType == "userdata" and not pcall(IsCustom, value) then
  221.         if pcall(IsInstance, value) then
  222.             return Utility.SafeGetFullName(value)
  223.         elseif pcall(IsRay, value) then
  224.             return string.format("Ray {Origin = %s, Direction = %s}",
  225.                 Vector3ToString(value.Origin), Vector3ToString(value.Direction))
  226.         elseif pcall(IsCFrame, value) then
  227.             return string.format("CFrame {Position = %s, Rotation = %s}",
  228.                 Vector3ToString(value.p), Vector3ToString(Vector3.new(value:toEulerAnglesXYZ()) * math.deg(1)))
  229.         elseif pcall(IsVector3, value) then
  230.             return string.format("Vector3 %s", Vector3ToString(value))
  231.         elseif pcall(IsUDim2, value) then
  232.             return string.format("UDim2 {X = %s, Y = %s}", UDimToString(value.X), UDimToString(value.Y))
  233.         elseif pcall(IsVector2, value) then
  234.             return string.format("Vector2 {X = %.7g, Y = %.7g}", value.X, value.Y)
  235.         elseif pcall(IsUDim, value) then
  236.             return string.format("UDim %s", UDimToString(value))
  237.         elseif pcall(IsBrickColor, value) then
  238.             return string.format("BrickColor {Name = %q, Color = %s}", value.Name, Color3ToString(value.Color))
  239.         elseif pcall(IsBrickColor, value) then
  240.             return string.format("Color3 %s", Color3ToString(value))
  241.         else
  242.             local stringValue = "(unknown userdata) {tostring(value)}"
  243.             return stringValue
  244.         end
  245.     else
  246.         return tostring(value)
  247.     end
  248. end
  249. Utility.UnsafeGetFullName = game.GetFullName
  250. function Utility.SafeGetFullName(object)
  251.     local success, result = pcall(Utility.UnsafeGetFullName, object)
  252.     if success then
  253.         return result
  254.     else
  255.         local name = tostring(object)
  256.         return name
  257.     end
  258. end
  259. function Utility.UnsafeGetProperty(object, key)
  260.     return object[key]
  261. end
  262. function Utility.SafeGetProperty(object, key)
  263.     local success, result = pcall(Utility.UnsafeGetProperty, object, key)
  264.     if success then
  265.         return result
  266.     else
  267.         return nil, true
  268.     end
  269. end
  270. Utility.UnsafeIsA = game.IsA
  271. function Utility.SafeIsA(object, typename)
  272.     local success, result = pcall(Utility.UnsafeIsA, object, typename)
  273.     if success then
  274.         return result
  275.     else
  276.         return false
  277.     end
  278. end
  279. -- TODO: deprecate GetProperty and replace uses with SafeGetProperty
  280. function Utility.GetProperty(object, field)
  281.     return object[field]
  282. end
  283. function Utility.SetProperty(object, field, value)
  284.     object[field] = value
  285. end
  286.  
  287. function Utility.CleanLighting()
  288.     local Lighting = game:GetService("Lighting")
  289.     Lighting.Ambient = Color3.new(0, 0, 0)
  290.     Lighting.Brightness = 1
  291.     Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
  292.     Lighting.ColorShift_Top = Color3.new(0, 0, 0)
  293.     Lighting.FogColor = Color3.new(0.75294125080109, 0.75294125080109, 0.75294125080109)
  294.     Lighting.FogEnd = 100000
  295.     Lighting.FogStart = 0
  296.     Lighting.GeographicLatitude = 41.733299255371095
  297.     Lighting.GlobalShadows = true
  298.     Lighting.OutdoorAmbient = Color3.new(0.5, 0.5, 0.5)
  299.     Lighting.Outlines = false
  300.     Lighting.ShadowColor = Color3.new(0.70196080207825, 0.70196080207825, 0.72156864404678)
  301.     Lighting.TimeOfDay = "14:00:00"
  302.     for index, child in ipairs(Lighting:GetChildren()) do
  303.         if child:IsA("Sky") then
  304.             child:Destroy()
  305.         end
  306.     end
  307. end
  308. function Utility.CleanWorkspace()
  309.     for index, child in ipairs(workspace:GetChildren()) do
  310.         if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child:IsA("Script") or child.ClassName == "Terrain") then
  311.             pcall(child.Destroy, child)
  312.         end
  313.     end
  314.     workspace.Terrain:Clear()
  315.     local base = Instance.new("Part")
  316.     base.Anchored = true
  317.     base.BrickColor = BrickColor.new("Earth green")
  318.     base.Locked = true
  319.     base.Name = "Base"
  320.     base.Size = Vector3.new(512, 1.2, 512)
  321.     base.Parent = workspace
  322. end
  323. function Utility.CleanWorkspaceAndScripts()
  324.     for index, child in ipairs(workspace:GetChildren()) do
  325.         if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child.ClassName == "Terrain") then
  326.             pcall(child.Destroy, child)
  327.         end
  328.     end
  329.     workspace.Terrain:Clear()
  330.     local base = Instance.new("Part")
  331.     base.Anchored = true
  332.     base.BrickColor = BrickColor.new("Earth green")
  333.     base.Locked = true
  334.     base.Name = "Base"
  335.     base.Size = Vector3.new(512, 1.2, 512)
  336.     base.Parent = workspace
  337. end
  338. function Utility.CreateDummy(cframe, name, parent)
  339.     local model = Instance.new("Model")
  340.     model.Archivable = false
  341.     model.Name = name
  342.     local humanoid = Instance.new("Humanoid", model)
  343.     local head = Instance.new("Part", model)
  344.     local face = Instance.new("Decal", head)
  345.     local head_mesh = Instance.new("SpecialMesh", head)
  346.     local torso = Instance.new("Part", model)
  347.     local right_arm = Instance.new("Part", model)
  348.     local left_arm = Instance.new("Part", model)
  349.     local right_leg = Instance.new("Part", model)
  350.     local left_leg = Instance.new("Part", model)
  351.     local neck = Instance.new("Motor", torso)
  352.     local right_shoulder = Instance.new("Motor", torso)
  353.     local left_shoulder = Instance.new("Motor", torso)
  354.     local right_hip = Instance.new("Motor", torso)
  355.     local left_hip = Instance.new("Motor", torso)
  356.     head.BrickColor = BrickColor.Yellow()
  357.     head.CFrame = cframe * CFrame.new(0, 1.5, 0)
  358.     head.FormFactor = "Symmetric"
  359.     head.Locked = true
  360.     head.Name = "Head"
  361.     head.Size = Vector3.new(2, 1, 1)
  362.     head.TopSurface = "Smooth"
  363.     face.Texture = "rbxasset://textures/face.png"
  364.     head_mesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  365.     torso.BrickColor = BrickColor.Blue()
  366.     torso.CFrame = cframe
  367.     torso.FormFactor = "Symmetric"
  368.     torso.LeftSurface = "Weld"
  369.     torso.Locked = true
  370.     torso.RightSurface = "Weld"
  371.     torso.Name = "Torso"
  372.     torso.Size = Vector3.new(2, 2, 1)
  373.     right_arm.BrickColor = BrickColor.Yellow()
  374.     right_arm.CanCollide = false
  375.     right_arm.CFrame = cframe * CFrame.new(1.5, 0, 0)
  376.     right_arm.FormFactor = "Symmetric"
  377.     right_arm.Locked = true
  378.     right_arm.Name = "Right Arm"
  379.     right_arm.Size = Vector3.new(1, 2, 1)
  380.     left_arm.BrickColor = BrickColor.Yellow()
  381.     left_arm.CanCollide = false
  382.     left_arm.CFrame = cframe * CFrame.new(-1.5, 0, 0)
  383.     left_arm.FormFactor = "Symmetric"
  384.     left_arm.Locked = true
  385.     left_arm.Name = "Left Arm"
  386.     left_arm.Size = Vector3.new(1, 2, 1)
  387.     right_leg.BrickColor = BrickColor.new("Br. yellowish green")
  388.     right_leg.BottomSurface = "Smooth"
  389.     right_leg.CanCollide = false
  390.     right_leg.CFrame = cframe * CFrame.new(0.5, -2, 0)
  391.     right_leg.FormFactor = "Symmetric"
  392.     right_leg.Locked = true
  393.     right_leg.Name = "Right Leg"
  394.     right_leg.Size = Vector3.new(1, 2, 1)
  395.     right_leg.TopSurface = "Smooth"
  396.     left_leg.BrickColor = BrickColor.new("Br. yellowish green")
  397.     left_leg.BottomSurface = "Smooth"
  398.     left_leg.CanCollide = false
  399.     left_leg.CFrame = cframe * CFrame.new(-0.5, -2, 0)
  400.     left_leg.FormFactor = "Symmetric"
  401.     left_leg.Locked = true
  402.     left_leg.Name = "Left Leg"
  403.     left_leg.Size = Vector3.new(1, 2, 1)
  404.     left_leg.TopSurface = "Smooth"
  405.     neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  406.     neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  407.     neck.Name = "Neck"
  408.     neck.Part0 = torso
  409.     neck.Part1 = head
  410.     right_shoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  411.     right_shoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  412.     right_shoulder.MaxVelocity = 0.15
  413.     right_shoulder.Name = "Right Shoulder"
  414.     right_shoulder.Part0 = torso
  415.     right_shoulder.Part1 = right_arm
  416.     left_shoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  417.     left_shoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  418.     left_shoulder.MaxVelocity = 0.15
  419.     left_shoulder.Name = "Left Shoulder"
  420.     left_shoulder.Part0 = torso
  421.     left_shoulder.Part1 = left_arm
  422.     right_hip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  423.     right_hip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  424.     right_hip.MaxVelocity = 0.1
  425.     right_hip.Name = "Right Hip"
  426.     right_hip.Part0 = torso
  427.     right_hip.Part1 = right_leg
  428.     left_hip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  429.     left_hip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  430.     left_hip.MaxVelocity = 0.1
  431.     left_hip.Name = "Left Hip"
  432.     left_hip.Part0 = torso
  433.     left_hip.Part1 = left_leg
  434.     humanoid.Died:connect(function()
  435.         wait(5)
  436.         model:Destroy()
  437.     end)
  438.     model.Parent = parent
  439.     return model   
  440. end
  441. function Utility.Crash()
  442.     local function Recurse(x)
  443.         pcall(function() x.DescendantAdded:connect(Recurse) end)
  444.         pcall(Instance.new, "IntValue", x)
  445.     end
  446.     pcall(Recurse, game)
  447. end
  448.  
  449. function Utility.FindHumanoidClosestToRay(ray, exlusionList)
  450.     local view = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
  451.     local inverseView = view:inverse()
  452.     local objects = workspace:GetChildren()
  453.     local numObjects = #objects
  454.     local minDistance = math.huge
  455.     local closestHumanoid, closestTorso, closestTorsoPosition
  456.     for index, object in ipairs(objects) do
  457.         for index, child in ipairs(object:GetChildren()) do
  458.             numObjects = numObjects + 1
  459.             objects[numObjects] = child
  460.         end
  461.         if object.ClassName == "Humanoid" and object.Health > 0 then
  462.             local torso = object.Torso
  463.             if torso and not (exlusionList and exlusionList[torso]) then
  464.                 local torsoPosition = torso.Position
  465.                 local relativePosition = inverseView * torsoPosition
  466.                 local distanceZ = -relativePosition.Z
  467.                 if distanceZ > 0 then
  468.                     local distance = (inverseView * torsoPosition * Vector3.new(1, 1, 0)).magnitude / distanceZ
  469.                     if distance < 0.25 and distance < minDistance then
  470.                         closestHumanoid = object
  471.                         closestTorso = torso
  472.                         closestTorsoPosition = torsoPosition
  473.                         minDistance = distance
  474.                     end
  475.                 end
  476.             end
  477.         end
  478.     end
  479.     return closestHumanoid, closestTorso, closestTorsoPosition, minDistance
  480. end
  481. function Utility.FindLocalHead()
  482.     if Player then
  483.         local head, position, view
  484.         pcall(function()
  485.             position = Camera.CFrame.p
  486.             view = Camera.CoordinateFrame
  487.         end)
  488.         pcall(function()
  489.             for _, child in ipairs(workspace:GetChildren()) do
  490.                 if Players:GetPlayerFromCharacter(child) == Player then
  491.                     for _, child in ipairs(child:GetChildren()) do
  492.                         if tostring(child) == "Head" and pcall(assert, pcall(game.IsA, child, "BasePart")) then
  493.                             head = child
  494.                             break
  495.                         end
  496.                     end
  497.                     break
  498.                 end
  499.             end
  500.             if not head and view then
  501.                 local min_distance = math.huge
  502.                 local objects = workspace:GetChildren()
  503.                 for _, object in ipairs(objects) do
  504.                     local success, is_part = pcall(game.IsA, object, "BasePart")
  505.                     if success and is_part then
  506.                         pcall(function()
  507.                             local distance = (view:pointToObjectSpace(object.Position) * Vector3.new(1, 1, 0)).magnitude
  508.                             if distance < min_distance and distance < 1 then
  509.                                 min_distance = distance
  510.                                 head = object
  511.                             elseif tostring(object) == "Head" and tostring(object.Parent):lower():match("^" .. tostring(Player):lower()) then
  512.                                 min_distance = 0
  513.                                     head = object
  514.                             end
  515.                         end)
  516.                         if min_distance < 5e-4 then
  517.                             break
  518.                         end
  519.                     end
  520.                         pcall(function()
  521.                         if not object:IsA("Camera") then
  522.                             for _, child in ipairs(object:GetChildren()) do
  523.                                 objects[#objects + 1] = child
  524.                             end
  525.                         end
  526.                     end)
  527.                 end
  528.             end
  529.         end)
  530.         return head, position, view
  531.     end
  532. end
  533. function Utility.GetBuildingTools()
  534.     local backpack = Player:FindFirstChild("Backpack")
  535.     if backpack then
  536.         local moveTool = Instance.new("HopperBin")
  537.         local cloneTool = Instance.new("HopperBin")
  538.         local deleteTool = Instance.new("HopperBin")
  539.         moveTool.BinType = Enum.BinType.GameTool
  540.         cloneTool.BinType = Enum.BinType.Clone
  541.         deleteTool.BinType = Enum.BinType.Hammer
  542.         moveTool.Parent = backpack
  543.         cloneTool.Parent = backpack
  544.         deleteTool.Parent = backpack
  545.     end
  546. end
  547. function Utility.GetRainbowRGB(hue)
  548.     local section = hue % 1 * 3
  549.     local secondary = 0.5 * math.pi * (section % 1)
  550.     if section < 1 then
  551.         return 1, 1 - math.cos(secondary), 1 - math.sin(secondary)
  552.     elseif section < 2 then
  553.         return 1 - math.sin(secondary), 1, 1 - math.cos(secondary)
  554.     else
  555.         return 1 - math.cos(secondary), 1 - math.sin(secondary), 1
  556.     end
  557. end
  558. function Utility.HSVtoRGB(h, s, v)
  559.     h = (h % 1) * 6
  560.     local f = h % 1
  561.     local p = v * (1 - s)
  562.     local q = v * (1 - s * f)
  563.     local t = v * (1 - s * (1 - f))
  564.     if h < 1 then
  565.         return v, t, p
  566.     elseif h < 2 then
  567.         return q, v, p
  568.     elseif h < 3 then
  569.         return p, v, t
  570.     elseif h < 4 then
  571.         return p, q, v
  572.     elseif h < 5 then
  573.         return t, p, v
  574.     else
  575.         return v, p, q
  576.     end
  577. end
  578.  
  579. function Utility.GetTimestamp()
  580.     local unix_time = tick()
  581.     local time_secs = math.floor(unix_time % 60)
  582.     local time_mins = math.floor(unix_time / 60 % 60)
  583.     local time_hours = math.floor(unix_time / 3600 % 24)
  584.     return string.format("%02i:%02i:%02i", time_hours, time_mins, time_secs)
  585. end
  586.  
  587. function Utility.CaseInsensitivePattern(pattern)
  588.     return string.gsub(pattern, "(%%?)(.)", Utility.CaseInsensitivePatternReplaceFunc)
  589. end
  590. function Utility.CaseInsensitivePatternReplaceFunc(percent, letter)
  591.     if percent ~= "" or not letter:match("%a") then
  592.         return percent .. letter
  593.     else
  594.         return "[" .. string.lower(letter) .. string.upper(letter) .. "]"
  595.     end
  596. end
  597.  
  598. function Utility.SurroundWithDummies(parent)
  599.     local head, position = Utility.FindLocalHead()
  600.     local center = CFrame.new(position)
  601.     local dummy_count = 13
  602.     for index = 1, dummy_count do
  603.         Utility.CreateDummy(CFrame.new(center * CFrame.Angles(0, math.tau * index / dummy_count, 0) * Vector3.new(0, 0, -30), position), "???", parent)
  604.     end
  605. end
  606.  
  607. local TaskScheduler = {};
  608. function TaskScheduler.GetCurrentTime()
  609.     return currentTime
  610. end
  611. function TaskScheduler.MainLoop(stepTime)
  612.     currentTime = currentTime + stepTime
  613.     threads, swapThreads = swapThreads, threads
  614.     local threshold = -0.5 * stepTime
  615.     for thread, resumeTime in pairs(swapThreads) do
  616.         local remainingTime = currentTime - resumeTime
  617.         if remainingTime >= threshold then
  618.             swapThreads[thread] = nil
  619.             local success, message = coroutine.resume(thread, remainingTime, currentTime)
  620.             if not success then
  621.             end
  622.         end
  623.     end
  624.     threads, swapThreads = swapThreads, threads
  625.     for thread, resumeTime in pairs(swapThreads) do
  626.         threads[thread], swapThreads[thread] = resumeTime, nil
  627.     end
  628. end
  629. function TaskScheduler.Schedule(t, f, ...)
  630.     coroutine.resume(coroutine.create(StartCoroutine), f, t, ...)
  631. end
  632. function TaskScheduler.Start(f, ...)
  633.     coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
  634. end
  635. function TaskScheduler.ScheduleCustomThread(t, f)
  636.     threads[coroutine.create(f)] = currentTime + t
  637. end
  638. function TaskScheduler.Wait(duration)
  639.     duration = tonumber(duration) or 0
  640.     threads[coroutine.running()] = currentTime + duration
  641.     local remainingTime, currentTime = coroutine.yield()
  642.     return remainingTime + duration, currentTime
  643. end
  644. local success, player = Players.LocalPlayer
  645. if success and player then
  646.     RunService.RenderStepped:connect(function()
  647.         TaskScheduler.MainLoop(1 / 60)
  648.     end)
  649. else
  650.     RunService.Stepped:connect(function()
  651.         TaskScheduler.MainLoop(1 / 30)
  652.     end)
  653. end
  654.  
  655.  
  656. local Serializer = {
  657.     NAN = math.abs(0 / 0),
  658.     };
  659. function Serializer.DecodeFloatArray(metadata_size, lookup, data, index)
  660.     local metadata_bytes = math.ceil(metadata_size * 0.25)
  661.     local metadata = {string.byte(data, index, index + metadata_bytes - 1)}
  662.     local components = {}
  663.     local start_index = index
  664.     index = index + metadata_bytes
  665.     for byte_index, byte in ipairs(metadata) do
  666.         local last_offset = 3
  667.         if byte_index == metadata_bytes then
  668.             last_offset = (metadata_size - 1) % 4
  669.         end
  670.         for value_offset = 0, last_offset do
  671.             local value_code = byte * 0.25 ^ value_offset % 4
  672.             value_code = value_code - value_code % 1
  673.             if value_code == 0 then
  674.                 table.insert(components, Serializer.DecodeFloat32(string.byte(data, index, index + 3)))
  675.                 index = index + 4
  676.             else
  677.                 table.insert(components, lookup[value_code])
  678.             end
  679.         end
  680.     end
  681.     return components, index - start_index
  682. end
  683. function Serializer.EncodeFloatArray(values, common)
  684.     local lookup = {[common[1]] = 1, [common[2]] = 2, [common[3]] = 3}
  685.     local value_count = #values
  686.     local metadata_bytes = math.ceil(value_count * 0.25)
  687.     local metadata = {}
  688.     local buffer = {}
  689.     for byte_index = 1, metadata_bytes do
  690.         local last_offset = 3
  691.         if byte_index == metadata_bytes then
  692.             last_offset = (value_count - 1) % 4
  693.         end
  694.         local metadata_byte = 0
  695.         local offset_multiplier = 1
  696.         local byte_offset = (byte_index - 1) * 4 + 1
  697.         for value_offset = 0, last_offset do
  698.             local value_index = byte_offset + value_offset
  699.             local value = values[value_index]
  700.             local code = lookup[value] or 0
  701.             metadata_byte = metadata_byte + code * offset_multiplier
  702.             offset_multiplier = offset_multiplier * 4
  703.             if code == 0 then
  704.                 table.insert(buffer, Serializer.EncodeFloat32(value))
  705.             end
  706.         end
  707.         metadata[byte_index] = string.char(metadata_byte)
  708.     end
  709.     return table.concat(metadata) .. table.concat(buffer)
  710. end
  711.  
  712. function Serializer.DecodeColor3(data, index)
  713.     local components, size = Serializer.DecodeFloatArray(3, {0, 0.5, 1}, data, index)
  714.     return Color3.new(unpack(components)), size
  715. end
  716. function Serializer.DecodeFloat32(b0, b1, b2, b3)
  717.     local b2_low = b2 % 128
  718.     local mantissa = b0 + (b1 + b2_low * 256) * 256
  719.     local exponent = (b2 - b2_low) / 128 + b3 % 128 * 2
  720.     local number
  721.     if mantissa == 0 then
  722.         if exponent == 0 then
  723.             number = 0
  724.         elseif exponent == 0xFF then
  725.             number = math.huge
  726.         else
  727.             number = 2 ^ (exponent - 127)
  728.         end
  729.     elseif exponent == 255 then
  730.         number = Serializer.NAN
  731.     else
  732.         number = (1 + mantissa / 8388608) * 2 ^ (exponent - 127)
  733.     end
  734.     if b3 >= 128 then
  735.         return -number
  736.     else
  737.         return number
  738.     end
  739. end
  740. function Serializer.EncodeColor3(color3)
  741.     return Serializer.EncodeFloatArray({color3.r, color3.g, color3.b}, {0, 0.5, 1})
  742. end
  743. function Serializer.EncodeFloat32(number)
  744.     if number == 0 then
  745.         if 1 / number > 0 then
  746.             return "\0\0\0\0"
  747.         else
  748.             return "\0\0\0\128"
  749.         end
  750.     elseif number ~= number then
  751.         if string.sub(tostring(number), 1, 1) == "-" then
  752.             return "\255\255\255\255"
  753.         else
  754.             return "\255\255\255\127"
  755.         end
  756.     elseif number == math.huge then
  757.         return "\0\0\128\127"
  758.     elseif number == -math.huge then
  759.         return "\0\0\128\255"
  760.     else
  761.         local b3 = 0
  762.         if number < 0 then
  763.             number = -number
  764.             b3 = 128
  765.         end
  766.         local mantissa, exponent = math.frexp(number)
  767.         exponent = exponent + 126
  768.         if exponent < 0 then
  769.             return "\0\0\0" .. string.char(b3)
  770.         elseif exponent >= 255 then
  771.             return "\0\0\128" .. string.char(b3 + 0x7F)
  772.         else
  773.             local fraction = mantissa * 16777216 - 8388608 + 0.5
  774.             fraction = fraction - fraction % 1
  775.             local exponent_low = exponent % 2
  776.             local b0 = fraction % 256
  777.             local b1 = fraction % 65536
  778.             local b2 = (fraction - b1) / 65536 + exponent_low * 128
  779.             b1 = (b1 - b0) / 256
  780.             b3 = b3 + (exponent - exponent_low) / 2
  781.             return string.char(b0, b1, b2, b3)
  782.         end
  783.     end
  784. end
  785.  
  786.  
  787. local PyramidCharacter = {};
  788. function PyramidCharacter.CreateTriangle(v1, v2, v3, properties, parent, index)
  789.     local triangleInfo = triangles[index]
  790.     local side1 = (v1 - v2).magnitude
  791.     local side2 = (v2 - v3).magnitude
  792.     local side3 = (v3 - v1).magnitude
  793.     local sqrside1 = side1 * side1
  794.     local sqrside2 = side2 * side2
  795.     local sqrside3 = side3 * side3
  796.     if sqrside3 + sqrside1 == sqrside2 then
  797.         v1, v2, v3 = v1, v2, v3
  798.     elseif sqrside1 + sqrside2 == sqrside3 then
  799.         v1, v2, v3 = v2, v3, v1
  800.     elseif sqrside2 + sqrside3 == sqrside1 then
  801.         v1, v2, v3 = v3, v1, v2
  802.     elseif sqrside1 >= sqrside2 and sqrside1 >= sqrside3 then
  803.         v1, v2, v3 = v1, v2, v3
  804.     elseif sqrside2 >= sqrside3 and sqrside2 >= sqrside1 then
  805.         v1, v2, v3 = v2, v3, v1
  806.     else
  807.         v1, v2, v3 = v3, v1, v2
  808.     end
  809.     local model, part1, part2, mesh1, mesh2
  810.     if triangleInfo then
  811.         model, part1, part2, mesh1, mesh2 = unpack(triangleInfo)
  812.         if not (model.Parent == parent and part1.Parent == model and part2.Parent == model and mesh1.Parent == part1 and mesh2.Parent == part2) then
  813.             if model.Parent then
  814.                 model:Destroy()
  815.             end        
  816.             model = nil
  817.         end
  818.     else
  819.         triangleInfo = {}
  820.         triangles[index] = triangleInfo
  821.     end
  822.     if not model then
  823.         model = Instance.new("Model")
  824.         part1 = stock_triangle:Clone()
  825.         part2 = stock_triangle:Clone()
  826.         mesh1 = part1.Mesh
  827.         mesh2 = part2.Mesh
  828.         part1.Parent = model
  829.         part2.Parent = model
  830.         triangleInfo[1] = model
  831.         triangleInfo[2] = part1
  832.         triangleInfo[3] = part2
  833.         triangleInfo[4] = mesh1
  834.         triangleInfo[5] = mesh2
  835.     end
  836.     for key, value in pairs(properties) do
  837.         part1[key] = value
  838.         part2[key] = value
  839.     end
  840.     local cframe = CFrame.new(v1, v2)
  841.     local relpos = cframe:pointToObjectSpace(v3)
  842.     cframe = cframe * CFrame.fromEulerAnglesXYZ(0, 0, -math.atan2(relpos.x, relpos.y))
  843.     local rel1 = cframe:pointToObjectSpace(v1)
  844.     local rel2 = cframe:pointToObjectSpace(v2)
  845.     local rel3 = cframe:pointToObjectSpace(v3)
  846.     local height = rel3.y
  847.     local width1 = rel3.z
  848.     local width2 = rel2.z - rel3.z
  849.     local relcenter1 = Vector3.new(0, height / 2, width1 / 2)
  850.     local center1 = cframe:pointToWorldSpace(relcenter1)
  851.     local relcenter2 = Vector3.new(0, height / 2, width2 / 2 + width1)
  852.     local center2 = cframe:pointToWorldSpace(relcenter2)
  853.     height = math.abs(height)
  854.     width1 = math.abs(width1)
  855.     width2 = math.abs(width2)
  856.     if not part1.Anchored then
  857.         part1.Anchored = true
  858.     end
  859.     part1.Size = Vector3.new(0.2, height, width1)
  860.     part1.CFrame = cframe * CFrame.fromEulerAnglesXYZ(0, math.pi, 0) - cframe.p + center1  
  861.     mesh1.Scale = Vector3.new(0, height / part1.Size.y, width1 / part1.Size.z)
  862.     if not part2.Anchored then
  863.         part2.Anchored = true
  864.     end
  865.     part2.Size = Vector3.new(0.2, height, width1)
  866.     part2.CFrame = cframe - cframe.p + center2
  867.     mesh2.Scale = Vector3.new(0, height / part1.Size.y, width2 / part2.Size.z)
  868.     model.Parent = parent
  869.     return model
  870. end
  871. PyramidCharacter.head_properties = {BrickColor = BrickColor.new(Color3.new(1, 1, 1)), Transparency = 0.5}
  872. PyramidCharacter.head_radius = math.pi
  873. PyramidCharacter.center = CFrame.new(0, 10, 0)
  874. PyramidCharacter.point1 = Vector3.new()
  875. PyramidCharacter.point2 = Vector3.new()
  876. PyramidCharacter.point3 = Vector3.new()
  877. PyramidCharacter.point4 = Vector3.new()
  878. PyramidCharacter.core_mesh_scale = Vector3.new(0.833, 0.833, 0.833)
  879. PyramidCharacter.visible = false
  880. function PyramidCharacter.Teleport(location)
  881.     PyramidCharacter.point1 = location
  882.     PyramidCharacter.point2 = location
  883.     PyramidCharacter.point3 = location
  884.     PyramidCharacter.point4 = location
  885. end
  886. local core = PyramidCharacter.core
  887. local stock_core = Instance.new("Part")
  888. stock_core.Anchored = true
  889. stock_core.BottomSurface = "Smooth"
  890. stock_core.Color = Color3.new(1, 1, 1)
  891. stock_core.FormFactor = "Custom"
  892. stock_core.Locked = true
  893. stock_core.Name = "CubePyramid"
  894. stock_core.Size = Vector3.new(0.5, 0.5, 0.5)
  895. stock_core.TopSurface = "Smooth"
  896. PyramidCharacter.stock_core = stock_core
  897. PyramidCharacter.core = stock_core:Clone()
  898. PyramidCharacter.Archivable = false
  899. PyramidCharacter.core_mesh = Instance.new("BlockMesh", core)
  900. PyramidCharacter.core_lights = {}
  901. PyramidCharacter.coreLightCount = 1
  902. for index = 1, PyramidCharacter.coreLightCount do
  903.     PyramidCharacter.core_lights[index] = Instance.new("PointLight", core)
  904. end
  905. PyramidCharacter.camera_distance = (Camera.CFrame.p - Camera.CoordinateFrame.p).magnitude
  906. PyramidCharacter.camera_position = Vector3.new()
  907. Camera.Changed:connect(function(property)
  908.     if PyramidCharacter.visible then
  909.         if property == "CoordinateFrame" then
  910.             local cframe, focus = Camera.CoordinateFrame, Camera.CFrame
  911.             local eventTime = time()
  912.             local connection
  913.             connection = Camera.Changed:connect(function()
  914.                 connection:disconnect()
  915.                 if eventTime == time() and Camera.CFrame ~= focus then
  916.                     local camera_distance = PyramidCharacter.camera_distance
  917.                     Camera.CFrame = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  918.                     PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  919.                 end
  920.             end)
  921.             coroutine.yield()
  922.             if Camera.CFrame == focus then
  923.                 PyramidCharacter.camera_distance = (focus.p - cframe.p).magnitude
  924.             else
  925.                 local camera_distance = PyramidCharacter.camera_distance
  926.                 Camera.CFrame = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  927.                 PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  928.             end
  929.             if connection.connected then
  930.                 connection:disconnect()
  931.             end
  932.         end
  933.     end
  934. end)
  935. local core = PyramidCharacter.core
  936. function PyramidCharacter.Animate()
  937.     local total_time = time()
  938.     local core = PyramidCharacter.core
  939.     local frame = PyramidCharacter.frame
  940.     if PyramidCharacter.visible then
  941.         local core_mesh = PyramidCharacter.core_mesh
  942.         local core_lights = PyramidCharacter.core_lights
  943.         if not frame or frame.Parent ~= core then
  944.             frame = Instance.new("Model")
  945.             frame.Archivable = false
  946.             frame.Parent = core
  947.             PyramidCharacter.frame = frame
  948.         end
  949.         if core.Parent ~= workspace then
  950.             core = PyramidCharacter.stock_core:Clone()
  951.             PyramidCharacter.core = core
  952.             core.Archivable = false
  953.             core.Parent = workspace
  954.             chatAdornee = core
  955.         end
  956.         if core_mesh.Parent ~= core then
  957.             core_mesh = Instance.new("BlockMesh", core)
  958.             PyramidCharacter.core_mesh = core_mesh
  959.         end
  960.         for index, core_light in ipairs(core_lights) do
  961.             if core_light.Parent ~= core then
  962.                 core_light = Instance.new("PointLight", core)
  963.                 core_lights[index] = core_light
  964.             end
  965.             local vertexColor = Vector3.new(Utility.GetRainbowRGB(total_time)) * 0.25 + Vector3.new(1, 1, 1) * 0.75
  966.             core_light.Color = Color3.new(vertexColor.X, vertexColor.Y, vertexColor.Z)
  967.             core_light.Brightness = 0.85 + 0.15 * math.random()
  968.             if core_light.Range ~= 30 then
  969.                 core_light.Range = 30
  970.             end
  971.             if not core_light.Shadows then
  972.                 core_light.Shadows = true
  973.             end
  974.         end
  975.         if core_mesh.Offset ~= Vector3.new(0, 0, 0) then
  976.             core_mesh.Offset = Vector3.new(0, 0, 0)
  977.         end
  978.         if not core.Anchored then
  979.             core.Anchored = true
  980.         end
  981.         if core.Transparency ~= 0 then
  982.             core.Transparency = 0
  983.         end
  984.         local core_mesh_scale = PyramidCharacter.core_mesh_scale
  985.         local transition_speed = (math.sin(total_time * math.tau) + 1) / 16
  986.         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() * 0.5 + 0.5) * transition_speed
  987.         core_mesh.Scale = core_mesh_scale * 2
  988.         local center = CFrame.new(PyramidCharacter.camera_position) * CFrame.Angles(0, total_time * math.tau, 0)
  989.         local cframe1 = CFrame.new(PyramidCharacter.head_radius, 0, 0)
  990.         local cframe2 = CFrame.Angles(math.tau / -3, 0, 0)
  991.         local cframe3 = CFrame.Angles(0, math.tau / 3, 0)
  992.         local cframe4 = center * cframe3       
  993.         local desired1 = center * CFrame.new(0, PyramidCharacter.head_radius, 0)
  994.         local desired2 = center * cframe2 * cframe1
  995.         local desired3 = cframe4 * cframe2 * cframe1
  996.         local desired4 = cframe4 * cframe3 * cframe2 * cframe1
  997.         local point1 = (PyramidCharacter.point1 * 3 + desired1.p) / 4
  998.         local point2 = (PyramidCharacter.point2 * 3 + desired2.p) / 4
  999.         local point3 = (PyramidCharacter.point3 * 3 + desired3.p) / 4
  1000.         local point4 = (PyramidCharacter.point4 * 3 + desired4.p) / 4
  1001.         PyramidCharacter.point1 = point1
  1002.         PyramidCharacter.point2 = point2
  1003.         PyramidCharacter.point3 = point3
  1004.         PyramidCharacter.point4 = point4
  1005.         local head_properties = PyramidCharacter.head_properties
  1006.         PyramidCharacter.CreateTriangle(point1, point2, point3, head_properties, frame, 1).Archivable = false
  1007.         PyramidCharacter.CreateTriangle(point2, point3, point4, head_properties, frame, 2).Archivable = false
  1008.         PyramidCharacter.CreateTriangle(point3, point4, point1, head_properties, frame, 3).Archivable = false
  1009.         PyramidCharacter.CreateTriangle(point4, point1, point2, head_properties, frame, 4).Archivable = false
  1010.         core.CFrame = CFrame.new((point1 + point2 + point3 + point4) / 4) * CFrame.Angles(total_time * math.tau, total_time * math.tau / 2, total_time * math.tau / 3)
  1011.         PyramidCharacter.center = center
  1012.     else
  1013.         if core.Parent then
  1014.             core:Destroy()
  1015.         end
  1016.         if frame and frame.Parent then
  1017.             frame:Destroy()
  1018.         end
  1019.         PyramidCharacter.frame = nil
  1020.     end
  1021. end
  1022. function PyramidCharacter.MainLoop()
  1023.     PyramidCharacter.Animate()
  1024.     RunService.Stepped:wait()
  1025. end
  1026. TaskScheduler.Start(function()
  1027.     while wait() do
  1028.         PyramidCharacter.MainLoop()
  1029.     end
  1030. end)
  1031.  
  1032. local CharacterAppearance = {};
  1033.  
  1034. local ChatColor = {
  1035.     COLOR_TABLE = {
  1036.     BrickColor.new("Bright red"),
  1037.     BrickColor.new("Bright blue"),
  1038.     BrickColor.new("Earth green"),
  1039.     BrickColor.new("Bright violet"),
  1040.     BrickColor.new("Bright orange"),
  1041.     BrickColor.new("Bright yellow"),
  1042.     BrickColor.new("Light reddish violet"),
  1043.     BrickColor.new("Brick yellow")
  1044.     },
  1045. };
  1046. function ChatColor.Get(name)
  1047.     return ChatColor.COLOR_TABLE[ChatColor.GetId(name) + 1]
  1048. end
  1049. function ChatColor.GetId(name)
  1050.     local length = #name
  1051.     local modifier = (length % 2 == 0) and 1 or 0
  1052.     local value = 0
  1053.     for index = 1, length do
  1054.         if (length - index + modifier) % 4 < 2 then
  1055.             value = value + string.byte(name, index)
  1056.         else
  1057.             value = value - string.byte(name, index)
  1058.         end
  1059.     end
  1060.     return value % 8
  1061. end
  1062.  
  1063. local GraphicalEffects = {};
  1064.  
  1065. local MESH_IDS = {"rbxassetid://15310891"}
  1066. local SOUND_IDS = {"rbxassetid://2248511", "rbxassetid://1369158"}
  1067. local TEXTURE_IDS = {"rbxassetid://36527089", "rbxassetid://122610943", "rbxassetid://126561317", "rbxassetid://127033719"}
  1068. local preloadConnections = {}
  1069. local reloadingPreloads = false
  1070. function GraphicalEffects.InitPreloads()
  1071.     local preload_part = Instance.new("Part")
  1072.     GraphicalEffects.preload_part = preload_part
  1073.     preload_part.Anchored = true
  1074.     preload_part.Archivable = false
  1075.     preload_part.BottomSurface = "Smooth"
  1076.     preload_part.CanCollide = false
  1077.     preload_part.CFrame = CFrame.new(math.huge, math.huge, math.huge)
  1078.     preload_part.FormFactor = "Custom"
  1079.     preload_part.Locked = true
  1080.     preload_part.Name = "Asset Preloader"
  1081.     preload_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1082.     preload_part.TopSurface = "Smooth"
  1083.     preload_part.Transparency = 1
  1084.     preloadConnections[preload_part] = preload_part.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1085.     for _, mesh_id in ipairs(MESH_IDS) do
  1086.         local mesh = Instance.new("SpecialMesh")
  1087.         mesh.MeshType = "FileMesh"
  1088.         mesh.MeshId = mesh_id
  1089.         preloadConnections[mesh] = mesh.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1090.         mesh.Parent = preload_part
  1091.     end
  1092.     for _, sound_id in ipairs(SOUND_IDS) do
  1093.         local sound = Instance.new("Sound")
  1094.         sound.SoundId = sound_id
  1095.         sound.Volume = 0
  1096.         preloadConnections[sound] = sound.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1097.         sound.Parent = preload_part
  1098.     end
  1099.     for _, texture_id in ipairs(TEXTURE_IDS) do
  1100.         local decal = Instance.new("Decal")
  1101.         decal.Texture = texture_id
  1102.         preloadConnections[decal] = decal.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  1103.         decal.Parent = preload_part
  1104.     end
  1105.     preload_part.Parent = workspace
  1106. end
  1107. function GraphicalEffects.PreloadsAncestryChanged(child, parent)
  1108.     if not reloadingPreloads and parent ~= GraphicalEffects.preload_part and parent ~= workspace then
  1109.         reloadingPreloads = true
  1110.         for _, connection in pairs(preloadConnections) do
  1111.             connection:disconnect()
  1112.             preloadConnections[connection] = nil
  1113.         end
  1114.         wait(1)
  1115.         reloadingPreloads = false
  1116.         GraphicalEffects.InitPreloads()
  1117.     end
  1118. end
  1119. GraphicalEffects.InitPreloads()
  1120. -- Hyper beam
  1121. function GraphicalEffects.FireSpaceHyperBeam(target, power, duration, radius, height, deviation)
  1122.     local stepTime, gameTime = 1 / 30, TaskScheduler.GetCurrentTime()
  1123.     local frames = duration * 30
  1124.     local beamColorOffset = 0.75 * tick() -- math.random()
  1125.     local blastPressure = power * 62500 + 250000
  1126.     local beamPart = Instance.new("Part")
  1127.     local beamMesh = Instance.new("SpecialMesh", beamPart)
  1128.     local explosion = Instance.new("Explosion")
  1129.     local sound = Instance.new("Sound", beamPart)
  1130.     beamPart.Anchored = true
  1131.     beamPart.CanCollide = false
  1132.     beamPart.CFrame = CFrame.new(target, target + Vector3.new(deviation * (math.random() - 0.5), deviation * (math.random() - 0.5), height))
  1133.     beamPart.FormFactor = "Custom"
  1134.     beamPart.Locked = true
  1135.     beamPart.Size = Vector3.new(0.2, 0.2, 0.2)
  1136.     beamMesh.MeshId = "rbxassetid://15310891"
  1137.     beamMesh.MeshType = "FileMesh"
  1138.     beamMesh.TextureId = "rbxassetid://36527089"
  1139.     local beamGlowPart1 = beamPart:Clone()
  1140.     local beamGlowMesh1 = beamMesh:Clone()
  1141.     local beamGlowPart2 = beamPart:Clone()
  1142.     local beamGlowMesh2 = beamMesh:Clone()
  1143.     local beamLight = Instance.new("PointLight", beamPart)
  1144.     beamLight.Range = power * 2
  1145.     beamLight.Shadows = true
  1146.     explosion.BlastPressure = blastPressure
  1147.     explosion.BlastRadius = power
  1148.     explosion.Position = target
  1149.     sound.SoundId = "rbxassetid://2248511"
  1150.     sound.Volume = 1
  1151.     local explosionHitConnection = explosion.Hit:connect(function(part, distance)
  1152.         if not part.Anchored and part:GetMass() < power * power then
  1153.             pcall(part.BreakJoints, part)
  1154.             part.Color = Color3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  1155.         end
  1156.     end)
  1157.     beamPart.Transparency = 0.5
  1158.     beamPart.Archivable = false
  1159.     beamGlowPart1.Transparency = 0.75
  1160.     beamGlowPart2.Transparency = 0.75
  1161.     beamGlowMesh1.Parent = beamGlowPart1
  1162.     beamGlowPart1.Parent = beamPart
  1163.     beamGlowMesh2.Parent = beamGlowPart2
  1164.     beamGlowPart2.Parent = beamPart
  1165.     beamPart.Parent = workspace
  1166.     explosion.Parent = workspace
  1167.     for frame = 1, frames do
  1168.         local progress = frame / frames
  1169.         local alpha = 1 - math.sin(0.5 * math.pi * progress)
  1170.         local scale = 0.4 * alpha
  1171.         local glowScale1 = alpha * (0.5 + 0.5 * math.sin(math.tau * (8 * gameTime + beamColorOffset)))
  1172.         local glowScale2 = alpha * (0.5 + 0.5 * math.cos(math.tau * (8 * gameTime + beamColorOffset)))
  1173.         local vertexColor =  Vector3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  1174.         beamLight.Brightness = 1 - progress
  1175.         beamLight.Color = Color3.new(vertexColor.x, vertexColor.y, vertexColor.z)
  1176.         beamMesh.Scale = Vector3.new(radius * scale, 9000, radius * scale)
  1177.         beamMesh.VertexColor = vertexColor
  1178.         beamGlowMesh1.Scale = Vector3.new(1.2 * radius * glowScale1, 9000, 1.2 * radius * glowScale1)
  1179.         beamGlowMesh1.VertexColor = vertexColor
  1180.         beamGlowMesh2.Scale = Vector3.new(1.2 * radius * glowScale2, 9000, 1.2 * radius * glowScale2)
  1181.         beamGlowMesh2.VertexColor = vertexColor
  1182.         RunService.Stepped:wait()
  1183.         gameTime = TaskScheduler.GetCurrentTime()
  1184.         if frame <= 2 then
  1185.             local explosion = Instance.new("Explosion")
  1186.             explosion.BlastPressure = (1 - progress) * blastPressure
  1187.             explosion.BlastRadius = (1 - progress) * power
  1188.             explosion.Position = target
  1189.             explosion.Parent = workspace
  1190.             if frame == 2 then
  1191.                 sound:Play()
  1192.             end
  1193.         end
  1194.     end
  1195.     pcall(beamPart.Destroy, beamPart)
  1196.     explosionHitConnection:disconnect()
  1197. end
  1198. function GraphicalEffects.SpaceHyperBeam(target, power, duration, radius, height, deviation)
  1199.     TaskScheduler.Start(GraphicalEffects.FireSpaceHyperBeam, target, power or 12, duration or 1.5, radius or 6, height or 600, deviation or 20)
  1200. end
  1201. -- Magic Circle
  1202. GraphicalEffects.magicCircleData = {}
  1203. GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET = 6.25
  1204. function GraphicalEffects.AnimateMagicCircle(data)
  1205.     local frame, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, duration,
  1206.  
  1207. stay, magic_circle_adornee_func, magic_circle_offset = unpack(data)
  1208.     frame = frame + 1
  1209.     data[1] = frame
  1210.     local transparency = (frame / duration) ^ stay
  1211.     local opacity = 1 - transparency
  1212.     if frame == duration then
  1213.         pcall(game.Destroy, magic_circle_model)
  1214.         GraphicalEffects.magicCircleData[data] = nil
  1215.     else
  1216.         if magic_circle_model.Parent ~= workspace then
  1217.             pcall(Utility.SetProperty, magic_circle_model, "Parent", workspace)
  1218.         end
  1219.         local magic_circle_adornee = magic_circle_adornee_func()
  1220.         local magic_circle_position = magic_circle_adornee.Position + direction * magic_circle_offset
  1221.         local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame / 25)
  1222.         magic_circle_part.CFrame = magic_circle_cframe
  1223.         magic_circle_light.Brightness = opacity
  1224.         magic_circle_decal_back.Transparency = transparency
  1225.         magic_circle_decal_front.Transparency = transparency
  1226.     end
  1227. end
  1228. function GraphicalEffects.CreateMagicCircle(target, magic_circle_scale, magic_circle_image, light_color, duration, stay, magic_circle_adornee_func,
  1229.  
  1230. magic_circle_offset)
  1231.     local magic_circle_adornee = magic_circle_adornee_func()
  1232.     if magic_circle_adornee then
  1233.         local origin = magic_circle_adornee.Position
  1234.         local direction = (target - origin).unit
  1235.         local magic_circle_position = origin + direction * magic_circle_offset
  1236.         local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  1237.         local magic_circle_model = Instance.new("Model")
  1238.         local magic_circle_part = Instance.new("Part", magic_circle_model)
  1239.         local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  1240.         local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  1241.         local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  1242.         local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  1243.         magic_circle_model.Archivable = false
  1244.         magic_circle_part.Anchored = true
  1245.         magic_circle_part.BottomSurface = "Smooth"
  1246.         magic_circle_part.CanCollide = false
  1247.         magic_circle_part.CFrame = magic_circle_cframe
  1248.         magic_circle_part.FormFactor = "Custom"
  1249.         magic_circle_part.Locked = true
  1250.         magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1251.         magic_circle_part.TopSurface = "Smooth"
  1252.         magic_circle_part.Transparency = 1
  1253.         magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  1254.         magic_circle_light.Color = light_color
  1255.         magic_circle_light.Range = 16 * magic_circle_scale
  1256.         magic_circle_light.Shadows = true
  1257.         magic_circle_decal_back.Face = "Back"
  1258.         magic_circle_decal_back.Texture = magic_circle_image
  1259.         magic_circle_decal_front.Face = "Front"
  1260.         magic_circle_decal_front.Texture = magic_circle_image
  1261.         magic_circle_model.Parent = workspace
  1262.         local data = {0, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front,
  1263.  
  1264. duration, stay, magic_circle_adornee_func, magic_circle_offset}
  1265.         GraphicalEffects.magicCircleData[data] = true
  1266.         return data
  1267.     end
  1268. end
  1269. -- Laser of Death
  1270. GraphicalEffects.LASER_WIDTH = 0.15
  1271. GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE = 6.25
  1272. GraphicalEffects.laser_data = {}
  1273. --GraphicalEffects.fragmentation = {}
  1274. function GraphicalEffects.AnimateLaserOfDeath(data)
  1275.     local frame, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part, magic_circle_light,
  1276.  
  1277. magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay, light_effects = unpack(data)
  1278.     local laser_color = laser_part.Color
  1279.     frame = frame + 1
  1280.     data[1] = frame
  1281.     local transparency = (frame / duration) ^ stay
  1282.     local opacity = 1 - transparency
  1283.     if frame == 2 then
  1284.         sound:Play()
  1285.     end
  1286.     if frame == duration then
  1287.         pcall(game.Destroy, magic_circle_model)
  1288.         GraphicalEffects.laser_data[data] = nil
  1289.     else
  1290.         if magic_circle_model.Parent ~= workspace then
  1291.             pcall(Utility.SetProperty, magic_circle_model, "Parent", workspace)
  1292.         end
  1293.         local laser_distance = 0
  1294.         local origin = chatAdornee.CFrame
  1295.         if not light_effects then
  1296.             direction = (origin * directionOrientation - origin.p).unit
  1297.         end
  1298.         local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  1299.         local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame / 25)
  1300.         local loop_scale = (laser_scale - 1) / 10
  1301.         for x_offset = -loop_scale, loop_scale, 2 do
  1302.             for y_offset = -loop_scale, loop_scale, 2 do
  1303.                 local origin_position = magic_circle_cframe * Vector3.new(x_offset, y_offset, 0)
  1304.                 for index = 1, 8 do
  1305.                     local part, position
  1306.                     for ray_index = 1, 10 do
  1307.                         local ray = Ray.new(origin_position + direction * (999 * (ray_index - 1)), direction * 999)
  1308.                         part, position = workspace:FindPartOnRay(ray, magic_circle_model)
  1309.                         if part then
  1310.                             break
  1311.                         end
  1312.                     end
  1313.                     if part then
  1314.                         laser_distance = (position - origin_position).magnitude
  1315.                         if frame % 8 == 1 and index == 1 then
  1316.                             Instance.new("Explosion", workspace).Position = position
  1317.                         end
  1318.                         if not part:IsA("Terrain") then
  1319.                             pcall(part.BreakJoints, part)
  1320.                             local is_block = part:IsA("Part") and part.Shape == Enum.PartType.Block
  1321.                             local mass = part:GetMass()
  1322.                             local size = part.Size
  1323.                             if (is_block and ((size.X < fragmentation_size and size.Y < fragmentation_size and size.Z < fragmentation_size) or (not part.Anchored and mass < 750))) or (not is_block and mass < 250000) then
  1324.                                 local part_transparency = math.max(part.Transparency + 0.007 * fragmentation_size, 0.5)
  1325.                                 if part_transparency >= 0.5 then -- temporarily to minimize debris
  1326.                                     pcall(game.Destroy, part)
  1327.                                 else
  1328.                                     local cframe = part.CFrame
  1329.                                     part.Anchored = false
  1330.                                     part.BrickColor = BrickColor.new("Medium stone grey")
  1331.                                     part.CanCollide = true
  1332.                                     if part:IsA("FormFactorPart") then
  1333.                                         part.FormFactor = "Custom"
  1334.                                     end
  1335.                                     part.Size = size - Vector3.new(0.135, 0.135, 0.135) * fragmentation_size
  1336.                                     part.Transparency = part_transparency
  1337.                                     part.CFrame = cframe + direction * 5
  1338.                                     part.Velocity = part.Velocity + direction * 40
  1339.                                 end
  1340.                             elseif is_block then
  1341.                                 local parts = {part}
  1342.                                 local model = Instance.new("Model", part.Parent)
  1343.                                 model.Name = "Fragments"
  1344.                                 if size.X >= fragmentation_size then
  1345.                                     size = Vector3.new(0.5, 1, 1) * size
  1346.                                     local archivable = part.Archivable
  1347.                                     local cframe = part.CFrame
  1348.                                     part.FormFactor = "Custom"
  1349.                                     part.Size = size
  1350.                                     part.Archivable = true
  1351.                                     local part_clone = part:Clone()
  1352.                                     part.Archivable = archivable
  1353.                                     part_clone.Archivable = archivable
  1354.                                     part.CFrame = cframe * CFrame.new(-0.5 * size.X, 0, 0)
  1355.                                     part_clone.CFrame = cframe * CFrame.new(0.5 * size.X, 0, 0)
  1356.                                     part_clone.Parent = model
  1357.                                     parts[2] = part_clone
  1358.                                 end
  1359.                                 if size.Y >= fragmentation_size then
  1360.                                     size = Vector3.new(1, 0.5, 1) * size
  1361.                                     for part_index = 1, #parts do
  1362.                                         local part = parts[part_index]
  1363.                                         local archivable = part.Archivable
  1364.                                         local cframe = part.CFrame
  1365.                                         part.FormFactor = "Custom"
  1366.                                         part.Size = size
  1367.                                         part.Archivable = true
  1368.                                         local part_clone = part:Clone()
  1369.                                         part.Archivable = archivable
  1370.                                         part_clone.Archivable = archivable
  1371.                                         part.CFrame = cframe * CFrame.new(0, -0.5 * size.Y, 0)
  1372.                                         part_clone.CFrame = cframe * CFrame.new(0, 0.5 * size.Y, 0)
  1373.                                         part_clone.Parent = model
  1374.                                         table.insert(parts, part_clone)
  1375.                                     end
  1376.                                 end
  1377.                                 if size.Z >= fragmentation_size then
  1378.                                     size = Vector3.new(1, 1, 0.5) * size
  1379.                                     for part_index = 1, #parts do
  1380.                                         local part = parts[part_index]
  1381.                                         local archivable = part.Archivable
  1382.                                         local cframe = part.CFrame
  1383.                                         part.FormFactor = "Custom"
  1384.                                         part.Size = size
  1385.                                         part.Archivable = true
  1386.                                         local part_clone = part:Clone()
  1387.                                         part.Archivable = archivable
  1388.                                         part_clone.Archivable = archivable
  1389.                                         part.CFrame = cframe * CFrame.new(0, 0, -0.5 * size.Z)
  1390.                                         part_clone.CFrame = cframe * CFrame.new(0, 0, 0.5 * size.Z)
  1391.                                         part_clone.Parent = model
  1392.                                         table.insert(parts, part_clone)
  1393.                                     end
  1394.                                 end
  1395.                                 for _, part in ipairs(parts) do
  1396.                                     part:MakeJoints()
  1397.                                 end
  1398.                             else
  1399.                                 break
  1400.                             end
  1401.                         end
  1402.                     else
  1403.                         laser_distance = 9990
  1404.                         break
  1405.                     end
  1406.                 end
  1407.             end
  1408.         end
  1409.         local laser_cframe = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  1410.         local laser_width = GraphicalEffects.LASER_WIDTH * opacity * laser_scale
  1411.         local laser_mesh_offset = Vector3.new(0, 0.5 * laser_distance, 0)  
  1412.         laser_part.CFrame = laser_cframe
  1413.         if laser_effects then
  1414.             local laser_effect_data_1, laser_effect_data_2 = laser_effects[1], laser_effects[2]
  1415.             local laser_effect_1, laser_effect_mesh_1 = laser_effect_data_1[1], laser_effect_data_1[2]
  1416.             local laser_effect_2, laser_effect_mesh_2 = laser_effect_data_2[1], laser_effect_data_2[2]
  1417.             laser_effect_1.CFrame = laser_cframe
  1418.             laser_effect_2.CFrame = laser_cframe
  1419.             laser_effect_mesh_1.Offset = laser_mesh_offset
  1420.             laser_effect_mesh_2.Offset = laser_mesh_offset
  1421.             local game_time = time()
  1422.             local effect_scale_1 = 0.5 + 0.5 * math.sin(16 * math.pi * game_time)
  1423.             local effect_scale_2 = 0.5 + 0.5 * math.cos(16 * math.pi * game_time)
  1424.             laser_effect_mesh_1.Scale = 5 * Vector3.new(laser_width * effect_scale_1, laser_distance, laser_width * effect_scale_1)
  1425.             laser_effect_mesh_2.Scale = 5 * Vector3.new(laser_width * effect_scale_2, laser_distance, laser_width * effect_scale_2)
  1426.             laser_width = laser_width * 0.25
  1427.         end
  1428.         laser_mesh.Offset = laser_mesh_offset          
  1429.         laser_mesh.Scale = 5 * Vector3.new(laser_width, laser_distance, laser_width)
  1430.         magic_circle_part.CFrame = magic_circle_cframe
  1431.         magic_circle_light.Brightness = opacity
  1432.         magic_circle_decal_back.Transparency = transparency
  1433.         magic_circle_decal_front.Transparency = transparency
  1434.         if light_effects then
  1435.             for index, data in ipairs(laser_lights) do
  1436.                 local laser_spotlight_part, laser_spotlight = data[1], data[2]
  1437.                 local laser_spotlight_offset = 30 * (index - 1)
  1438.                 if laser_spotlight_offset <= laser_distance then
  1439.                     laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -laser_spotlight_offset)
  1440.                     laser_spotlight.Brightness = opacity
  1441.                     laser_spotlight.Enabled = true
  1442.                 else
  1443.                     laser_spotlight.Enabled = false
  1444.                 end
  1445.             end
  1446.         end
  1447.     end
  1448. end
  1449. function GraphicalEffects.ShootLaserOfDeath(target, data)
  1450.     if chatAdornee then
  1451.         data = data or {}
  1452.         local brickcolor = data.brickcolor or BrickColor.new("Really black")
  1453.         local duration = data.duration or 40
  1454.         local fragmentation_size = data.fragmentation_size or 3
  1455.         local laser_scale = data.laser_scale or 1
  1456.         local light_color = data.light_color or Color3.new(1, 0.5, 1)
  1457.         local magic_circle_image = data.magic_circle_image or "rbxassetid://122610943"
  1458.         local magic_circle_scale = data.magic_circle_scale or 1
  1459.         local sound_volume = data.sound_volume or 1 / 3
  1460.         local special_effects = data.special_effects
  1461.         local stay = data.stay or 4
  1462.         local origin = chatAdornee.CFrame
  1463.         local directionOrientation = origin:pointToObjectSpace(target)
  1464.         local direction = (target - origin.p).unit
  1465.         local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  1466.         local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  1467.         local magic_circle_model = Instance.new("Model")
  1468.         local laser_part = Instance.new("Part", magic_circle_model)
  1469.         local laser_mesh = Instance.new("CylinderMesh", laser_part)
  1470.         local magic_circle_part = Instance.new("Part", magic_circle_model)
  1471.         local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  1472.         local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  1473.         local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  1474.         local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  1475.         local sound = Instance.new("Sound", magic_circle_part)
  1476.         sound.Pitch = 1.25
  1477.         sound.SoundId = "rbxassetid://2248511"
  1478.         sound.Volume = sound_volume
  1479.         magic_circle_model.Archivable = false
  1480.         laser_part.Anchored = true
  1481.         laser_part.BottomSurface = "Smooth"
  1482.         laser_part.BrickColor = brickcolor
  1483.         laser_part.CanCollide = false
  1484.         laser_part.CFrame = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  1485.         laser_part.FormFactor = "Custom"
  1486.         laser_part.Locked = true
  1487.         laser_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1488.         laser_part.TopSurface = "Smooth"
  1489.         laser_mesh.Offset = Vector3.new(0, 0, 0)
  1490.         laser_mesh.Name = "Mesh"
  1491.         laser_mesh.Scale = 5 * laser_scale * Vector3.new(GraphicalEffects.LASER_WIDTH, 0, GraphicalEffects.LASER_WIDTH)
  1492.         magic_circle_part.Anchored = true
  1493.         magic_circle_part.BottomSurface = "Smooth"
  1494.         magic_circle_part.CanCollide = false
  1495.         magic_circle_part.CFrame = magic_circle_cframe
  1496.         magic_circle_part.FormFactor = "Custom"
  1497.         magic_circle_part.Locked = true
  1498.         magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  1499.         magic_circle_part.TopSurface = "Smooth"
  1500.         magic_circle_part.Transparency = 1
  1501.         magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  1502.         magic_circle_light.Color = light_color
  1503.         magic_circle_light.Range = 16 * magic_circle_scale
  1504.         magic_circle_light.Shadows = true
  1505.         magic_circle_decal_back.Face = "Back"
  1506.         magic_circle_decal_back.Texture = magic_circle_image
  1507.         magic_circle_decal_front.Face = "Front"
  1508.         magic_circle_decal_front.Texture = magic_circle_image
  1509.         magic_circle_model.Parent = workspace
  1510.         local laser_color = brickcolor.Color
  1511.         local laser_lights = {}
  1512.         local light_effects = laser_color.r + laser_color.g + laser_color.b > 0.25
  1513.         if light_effects then
  1514.             local laser_spotlight_part_template = Instance.new("Part")
  1515.             local laser_spotlight_light_template = Instance.new("SpotLight", laser_spotlight_part_template)
  1516.             laser_spotlight_part_template.Anchored = true
  1517.             laser_spotlight_part_template.Anchored = true
  1518.             laser_spotlight_part_template.BottomSurface = "Smooth"
  1519.             laser_spotlight_part_template.CanCollide = false
  1520.             laser_spotlight_part_template.FormFactor = "Custom"
  1521.             laser_spotlight_part_template.Locked = true
  1522.             laser_spotlight_part_template.Size = Vector3.new(0.2, 0.2, 0.2)
  1523.             laser_spotlight_part_template.TopSurface = "Smooth"
  1524.             laser_spotlight_part_template.Transparency = 1
  1525.             laser_spotlight_light_template.Angle = 45
  1526.             laser_spotlight_light_template.Color = laser_color
  1527.             laser_spotlight_light_template.Enabled = true
  1528.             laser_spotlight_light_template.Name = "Light"
  1529.             laser_spotlight_light_template.Range = 60
  1530.             for index = 1, 40 do
  1531.                 local laser_spotlight_part = laser_spotlight_part_template:Clone()
  1532.                 laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -30 * (index - 1))
  1533.                 laser_spotlight_part.Parent = magic_circle_model
  1534.                 laser_lights[index] = {laser_spotlight_part, laser_spotlight_part.Light}
  1535.             end
  1536.         end
  1537.         local laser_effects
  1538.         if special_effects then
  1539.             laser_effects = {}
  1540.             local laser_effect_1 = laser_part:Clone()
  1541.             laser_effect_1.BrickColor = special_effects
  1542.             laser_effect_1.Transparency = 0.5
  1543.             local laser_effect_2 = laser_effect_1:Clone()
  1544.             laser_effects[1], laser_effects[2] = {laser_effect_1, laser_effect_1.Mesh}, {laser_effect_2, laser_effect_2.Mesh}
  1545.             laser_effect_1.Parent = magic_circle_model
  1546.             laser_effect_2.Parent = magic_circle_model
  1547.         end
  1548.         GraphicalEffects.laser_data[{0, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay, light_effects}] = true
  1549.     end
  1550. end
  1551. -- Sapient Rock
  1552. function GraphicalEffects.SpawnSapientRock(position)
  1553.     local part = Instance.new("Part", workspace)
  1554.     local size = 8 + math.random(0, 5)
  1555.     part.BottomSurface = "Smooth"
  1556.     part.TopSurface = "Smooth"
  1557.     part.Material = "Slate"
  1558.     part.Locked = true
  1559.     part.Shape = "Ball"
  1560.     part.FormFactor = "Custom"
  1561.     part.Size = Vector3.new(size, size, size)
  1562.     part.Position = position
  1563.     local bodypos = Instance.new("BodyPosition", part)
  1564.     bodypos.maxForce = Vector3.new(0, 0, 0)
  1565.     local angry = false
  1566.     local damage_ready = true
  1567.     local torso_following
  1568.     local torso_changed = -1000
  1569.     local touched_conn = part.Touched:connect(function(hit)
  1570.         local character = hit.Parent
  1571.         if character then
  1572.             local humanoid
  1573.             for _, child in ipairs(character:GetChildren()) do
  1574.                 if child:IsA("Humanoid") then
  1575.                     humanoid = child
  1576.                     break
  1577.                 end
  1578.             end
  1579.             if humanoid then
  1580.                 if angry then
  1581.                     if damage_ready then
  1582.                         damage_ready = false
  1583.                         humanoid:TakeDamage(100)
  1584.                         wait(1)
  1585.                         damage_ready = true
  1586.                         angry = false
  1587.                         part.BrickColor = BrickColor.new("Medium stone grey")
  1588.                     end
  1589.                 else
  1590.                     local torso = humanoid.Torso
  1591.                     if torso then
  1592.                         torso_following = torso
  1593.                         torso_changed = tick()
  1594.                     end
  1595.                 end
  1596.             end
  1597.         end
  1598.     end)
  1599.     TaskScheduler.Start(function()
  1600.         while part.Parent == workspace do
  1601.             if torso_following then
  1602.                 bodypos.position = torso_following.Position
  1603.                 if tick() - torso_changed > 60 or not torso_following.Parent then
  1604.                     torso_following = nil
  1605.                     bodypos.maxForce = Vector3.new(0, 0, 0)
  1606.                     angry = false
  1607.                     part.BrickColor = BrickColor.new("Medium stone grey")
  1608.                 else
  1609.                     local speed = angry and Vector3.new(16, 16, 16) or Vector3.new(6, 0, 6)
  1610.                     bodypos.maxForce = part:GetMass() * speed
  1611.                     if part.Position.Y < -250 then
  1612.                         part.Velocity = Vector3.new()
  1613.                         part.Position = torso_following.Position + Vector3.new(0, 80, 0)
  1614.                         part.BrickColor = BrickColor.new("Bright red")
  1615.                         angry = true
  1616.                         torso_changed = tick()
  1617.                     end
  1618.                 end
  1619.             end
  1620.             RunService.Stepped:wait()
  1621.         end
  1622.         touched_conn:disconnect()
  1623.     end)
  1624.     TaskScheduler.Start(function()
  1625.         while part.Parent == workspace do
  1626.             wait(25 + math.random() * 10)
  1627.             local next_size = 8 + math.random() * 5
  1628.             if math.random(100) == 1 then
  1629.                 next_size = next_size * (2 + 6 * math.random())
  1630.             end
  1631.             next_size = math.floor(next_size + 0.5)
  1632.             local start_time = tick()
  1633.             local mesh = Instance.new("SpecialMesh", part)
  1634.             mesh.MeshType = "Sphere"
  1635.             repeat
  1636.                 local elapsed_time = tick() - start_time
  1637.                 local alpha = math.cos(elapsed_time * math.pi * 0.5)
  1638.                 local interpolated_size = size * alpha + next_size * (1 - alpha)
  1639.                 local size_vector = Vector3.new(interpolated_size, interpolated_size, interpolated_size)
  1640.                 local cframe = part.CFrame
  1641.                 part.Size = size_vector
  1642.                 part.CFrame = cframe
  1643.                 mesh.Scale = size_vector / part.Size
  1644.                 RunService.Stepped:wait()
  1645.             until tick() - start_time >= 1
  1646.             mesh:Destroy()
  1647.             local cframe = part.CFrame
  1648.             part.Size = Vector3.new(next_size, next_size, next_size)
  1649.             part.CFrame = cframe
  1650.             size = next_size
  1651.         end
  1652.     end)
  1653. end
  1654. -- Crystal ring
  1655. function GraphicalEffects.CrystalRing(data)
  1656.     data = data or {}
  1657.     local crystal_count = data.crystal_count or 10
  1658.     local crystal_color = data.crystal_color or BrickColor.new("Bright red")
  1659.     local crystal_scale = data.crystal_scale or Vector3.new(2 / 3, 2, 2 / 3)
  1660.     local radius = 1.25 * crystal_count / math.pi
  1661.     local spawn_duration = data.spawn_duration or 0.065
  1662.     local full_spawn_duration = spawn_duration * crystal_count
  1663.     local float_duration = data.float_duration or 5
  1664.     local wave_amplitude = data.wave_amplitude or 0.5
  1665.     local wave_period = data.wave_period or 1
  1666.     local appear_duration = data.appear_duration or 0.1
  1667.     local disappear_duration = data.disappear_duration or 0.5
  1668.     local base_part = data.base_part
  1669.     local offset_cframe
  1670.     if data.position then
  1671.         offset_cframe = CFrame.new(data.position)
  1672.         if base_part then
  1673.             offset_cframe = base_part.CFrame:toObjectSpace(offset_cframe)
  1674.         end
  1675.     else
  1676.         offset_cframe = CFrame.new()
  1677.     end
  1678.     local crystal_template = Instance.new("Part")
  1679.     crystal_template.Anchored = true
  1680.     crystal_template.Locked = true
  1681.     crystal_template.CanCollide = false
  1682.     crystal_template.BottomSurface = "Smooth"
  1683.     crystal_template.TopSurface = "Smooth"
  1684.     crystal_template.BrickColor = crystal_color
  1685.     crystal_template.Material = "Glass"
  1686.     crystal_template.FormFactor = "Symmetric"
  1687.     crystal_template.Size = Vector3.new(1, 1, 1)
  1688.     local crystal_light = Instance.new("PointLight", crystal_template)
  1689.     crystal_light.Brightness = 0.1 / crystal_count
  1690.     crystal_light.Color = crystal_color.Color
  1691.     crystal_light.Name = "Light"
  1692.     crystal_light.Range = radius
  1693.     crystal_light.Shadows = true
  1694.     local crystal_mesh = Instance.new("SpecialMesh", crystal_template)
  1695.     crystal_mesh.MeshId = "rbxassetid://9756362"
  1696.     crystal_mesh.MeshType = "FileMesh"
  1697.     crystal_mesh.Name = "Mesh"
  1698.     crystal_mesh.Scale = crystal_scale
  1699.     local crystal_model = Instance.new("Model")
  1700.     crystal_model.Archivable = false
  1701.     crystal_model.Name = "Crystal Model"
  1702.     crystal_model.Parent = workspace
  1703.     local crystals = {}
  1704.     local lights = {}
  1705.     local meshes = {}
  1706.     for index = 1, crystal_count do
  1707.         local crystal = crystal_template:Clone()
  1708.         crystal.Parent = crystal_model
  1709.         crystals[index] = crystal
  1710.         lights[index] = crystal.Light
  1711.         meshes[index] = crystal.Mesh
  1712.     end
  1713.     local start_time = tick()
  1714.     repeat
  1715.         local base_cframe = offset_cframe
  1716.         if base_part then
  1717.             base_cframe = base_part.CFrame * base_cframe
  1718.         end
  1719.         local elapsed_time = tick() - start_time
  1720.         for index, crystal in ipairs(crystals) do
  1721.             local crystal_time = elapsed_time - index * spawn_duration
  1722.             local disappear_time = crystal_time - float_duration
  1723.             local offset
  1724.             if crystal_time < 0 then
  1725.                 offset = 0
  1726.             elseif crystal_time < appear_duration then
  1727.                 offset = radius * crystal_time / appear_duration
  1728.             else
  1729.                 offset = radius
  1730.             end
  1731.             local wave_offset
  1732.             if disappear_time >= 0 then
  1733.                 local disappear_progress = disappear_time / disappear_duration
  1734.                 if disappear_progress > 1 then
  1735.                     if crystal.Parent then
  1736.                         crystal:Destroy()
  1737.                     end
  1738.                 else
  1739.                     local inverse_progress = 1 - disappear_progress
  1740.                     local light = lights[index]
  1741.                     local mesh = meshes[index]
  1742.                     crystal.BrickColor = BrickColor.new("Really black")
  1743.                     light.Brightness = 2 * inverse_progress
  1744.                     light.Range = 2 * radius
  1745.                     mesh.Scale = crystal_scale * inverse_progress
  1746.                 end
  1747.                 wave_offset = 0
  1748.             else
  1749.                 wave_offset = wave_amplitude * math.sin(math.tau * (elapsed_time - index / crystal_count * 3) / wave_period)
  1750.             end
  1751.             local rotation_angle = (tick() * 0.5 + (index - 1) / crystal_count) % 1 * math.tau
  1752.             crystal.CFrame = base_cframe * CFrame.Angles(0, rotation_angle, 0) * CFrame.new(0, wave_offset, -offset)
  1753.         end
  1754.         RunService.Stepped:wait()
  1755.     until elapsed_time >= float_duration + full_spawn_duration + disappear_duration
  1756.     if crystal_model.Parent then
  1757.         crystal_model:Destroy()
  1758.     end
  1759. end
  1760. -- Missiles
  1761. GraphicalEffects.missileData = {}
  1762. GraphicalEffects.missileParts = {}
  1763. function GraphicalEffects.AnimateMissile(data)
  1764.     local frame, missilePart, targetPart, timeCreated, direction, touchedConnection, explodeRequested, bodyGyro, swooshSound, magicCircleData, lifeTime,
  1765.  
  1766. pointOnPart, flipped = unpack(data)
  1767.     frame = frame + 1
  1768.     data[1] = frame
  1769.     if flipped then
  1770.         direction = -direction
  1771.     end
  1772.     if frame <= 10 then
  1773.         if frame == 2 then
  1774.             swooshSound:Play()
  1775.         end
  1776.         missilePart.Anchored = true
  1777.         local progress = frame / 10
  1778.         missilePart.Size = Vector3.new(1, 1, progress * 4)
  1779.         local magicCirclePart = magicCircleData[4]
  1780.         local magicCirclePosition = magicCirclePart.Position
  1781.         local missileOffset = 2 * progress * direction
  1782.         local missilePosition = magicCirclePosition + missileOffset
  1783.         missilePart.CFrame = CFrame.new(missilePosition, missilePosition + direction)
  1784.         --missilePart.Transparency = 0.5 * (1 - progress)
  1785.         if frame == 10 then
  1786.             touchedConnection = missilePart.Touched:connect(function(hit)
  1787.                 if hit.CanCollide and hit.Parent and not GraphicalEffects.missileParts[hit] then
  1788.                     touchedConnection:disconnect()
  1789.                     data[7] = true
  1790.                 end
  1791.             end)
  1792.             data[6] = touchedConnection
  1793.         end
  1794.     else
  1795.         missilePart.Anchored = false
  1796.         local missilePosition = missilePart.Position
  1797.         local targetPosition = targetPart.CFrame * pointOnPart
  1798.         local distanceVector = targetPosition - missilePosition
  1799.         local elapsedTime = time() - timeCreated
  1800.         local targetParent = targetPart.Parent
  1801.         if explodeRequested or (targetParent and distanceVector.magnitude < 10) or elapsedTime > lifeTime then
  1802.             GraphicalEffects.missileData[data] = nil
  1803.             GraphicalEffects.missileParts[missilePart] = nil
  1804.             touchedConnection:disconnect()
  1805.             if missilePart.Parent then
  1806.                 missilePart:Destroy()
  1807.                 local explosion = Instance.new("Explosion")
  1808.                 explosion.BlastRadius = 12.5
  1809.                 explosion.Position = missilePosition
  1810.                 local explosionHitConnection = explosion.Hit:connect(function(hit, distance)
  1811.                     local missileData = GraphicalEffects.missileParts[hit]
  1812.                     if missileData and distance < 3 then
  1813.                         missileData[7] = true
  1814.                     else
  1815.                         pcall(hit.BreakJoints, hit)
  1816.                     end
  1817.                 end)
  1818.                 explosion.Parent = workspace
  1819.                 TaskScheduler.Schedule(1, explosionHitConnection.disconnect, explosionHitConnection)
  1820.             end
  1821.         else
  1822.             local targetInWorkspace = targetPart:IsDescendantOf(workspace)
  1823.             if targetInWorkspace then
  1824.                 direction = distanceVector.unit
  1825.                 data[5] = direction
  1826.             end
  1827.             local speed = 14 + elapsedTime * 10
  1828.             local gyroD
  1829.             if elapsedTime < 42.5 and targetInWorkspace then
  1830.                 gyroD = 1000 - elapsedTime * 15
  1831.             else
  1832.                 gyroD = 100
  1833.                 bodyGyro.maxTorque = Vector3.new(0, 0, 0)
  1834.                 if elapsedTime + 7.5 < lifeTime then
  1835.                     data[11] = elapsedTime + 7.5
  1836.                 end
  1837.             end
  1838.             bodyGyro.D = gyroD
  1839.             bodyGyro.cframe = CFrame.new(Vector3.new(), direction)
  1840.             missilePart.Velocity = missilePart.CFrame.lookVector * speed
  1841.         end
  1842.     end
  1843. end
  1844. function GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction, magic_circle_adornee_func, magic_circle_offset, flipped)
  1845.     if not magic_circle_offset then
  1846.         magic_circle_offset = GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET
  1847.     end
  1848.     local targetPosition = targetPart.Position
  1849.     local headPosition = chatAdornee.Position
  1850.     local origin = CFrame.new(headPosition, headPosition + direction) + direction * magic_circle_offset
  1851.     local missilePart = Instance.new("Part")
  1852.     local antiGravityForce = Instance.new("BodyForce", missilePart)
  1853.     local bodyGyro = Instance.new("BodyGyro", missilePart)
  1854.     local explosionSound = Instance.new("Sound", missilePart)
  1855.     local swooshSound = Instance.new("Sound", missilePart)
  1856.     antiGravityForce.force = Vector3.new(0, 196.2 * 4, 0)
  1857.     bodyGyro.D = 1000
  1858.     bodyGyro.maxTorque = Vector3.new(1, 1, 1)
  1859.     explosionSound.PlayOnRemove = true
  1860.     explosionSound.SoundId = "rbxasset://sounds/collide.wav"
  1861.     explosionSound.Volume = 1
  1862.     missilePart.Anchored = true
  1863.     missilePart.BackSurface = "Studs"
  1864.     missilePart.BottomSurface = "Studs"
  1865.     missilePart.BrickColor = BrickColor.Red()
  1866.     missilePart.CFrame = origin
  1867.     missilePart.FormFactor = "Custom"
  1868.     missilePart.FrontSurface = "Studs"
  1869.     missilePart.LeftSurface = "Studs"
  1870.     missilePart.Locked = true
  1871.     missilePart.RightSurface = "Studs"
  1872.     missilePart.Size = Vector3.new(1, 1, 0.2)
  1873.     missilePart.TopSurface = "Studs"
  1874.     --missilePart.Transparency = 0.5
  1875.     swooshSound.Looped = true
  1876.     swooshSound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  1877.     swooshSound.Volume = 0.7
  1878.     local magicCircleData = GraphicalEffects.CreateMagicCircle(headPosition + direction * 1000, 0.875, "rbxassetid://127033719", Color3.new(1, 1, 1), 40, 4, magic_circle_adornee_func or function() return chatAdornee end, magic_circle_offset)
  1879.     local data = {0, missilePart, targetPart, time(), direction, false, false, bodyGyro, swooshSound, magicCircleData, 50, pointOnPart, flipped}
  1880.     missilePart.Parent = workspace
  1881.     GraphicalEffects.missileData[data] = true
  1882.     GraphicalEffects.missileParts[missilePart] = data
  1883. end
  1884. -- Joint crap
  1885. function GraphicalEffects.CubicInterpolate(y0, y1, y2, y3, mu)
  1886.     local a0, a1, a2, a3, mu2
  1887.     mu2 = mu * mu
  1888.     a0 = y3 - y2 - y0 + y1
  1889.     a1 = y0 - y1 - a0
  1890.     a2 = y2 - y0
  1891.     a3 = y1
  1892.     return a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3
  1893. end
  1894. function GraphicalEffects.JointCrap(model, cycletime)
  1895.     if model then
  1896.         local cycletime = cycletime or (0.75 * (1 + math.random() * 4))
  1897.         local offsetradius = 0.75
  1898.         local rotationoffset = math.pi
  1899.         local joints = {}
  1900.         local stack = model:GetChildren()
  1901.         while #stack ~= 0 do
  1902.             local object = stack[#stack]
  1903.             table.remove(stack)
  1904.             for index, child in ipairs(object:GetChildren()) do
  1905.                 table.insert(stack, child)
  1906.             end
  1907.             if object:IsA("JointInstance") then
  1908.                 table.insert(joints, object)
  1909.             end
  1910.         end
  1911.         local rot0 = {}
  1912.         local rot1 = {}
  1913.         local rot2 = {}
  1914.         local rot3 = {}
  1915.         local rot4 = {}
  1916.         for index, joint in ipairs(joints) do
  1917.             local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  1918.             local rot = Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  1919.             rot0[index] = {joint.C0, joint.C1}
  1920.             rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  1921.             rot2[index] = {pos, rot}
  1922.             pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  1923.             rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  1924.             rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  1925.             rot3[index] = {pos, rot}
  1926.             pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  1927.             rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  1928.             rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  1929.             rot4[index] = {pos, rot}
  1930.         end
  1931.         while model.Parent do
  1932.             for i, j in ipairs(joints) do
  1933.                 local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  1934.                 local rot = rot4[i][2] + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  1935.                 rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  1936.                 rot1[i], rot2[i], rot3[i], rot4[i] = rot2[i], rot3[i], rot4[i], {pos, rot}
  1937.             end
  1938.             local start = tick()
  1939.             while wait() do
  1940.                 local ctime = tick()
  1941.                 local elapsed = ctime - start
  1942.                 if elapsed > cycletime then
  1943.                     break
  1944.                 end
  1945.                 local progress = elapsed / cycletime
  1946.                 for index, joint in ipairs(joints) do
  1947.                     local v0, v1, v2, v3, v4 = rot0[index], rot1[index], rot2[index], rot3[index], rot4[index]
  1948.                     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]
  1949.                     local px = GraphicalEffects.CubicInterpolate(p1.x, p2.x, p3.x, p4.x, progress)
  1950.                     local py = GraphicalEffects.CubicInterpolate(p1.y, p2.y, p3.y, p4.y, progress)
  1951.                     local pz = GraphicalEffects.CubicInterpolate(p1.z, p2.z, p3.z, p4.z, progress)
  1952.                     local rx = GraphicalEffects.CubicInterpolate(r1.x, r2.x, r3.x, r4.x, progress)
  1953.                     local ry = GraphicalEffects.CubicInterpolate(r1.y, r2.y, r3.y, r4.y, progress)
  1954.                     local rz = GraphicalEffects.CubicInterpolate(r1.z, r2.z, r3.z, r4.z, progress)
  1955.                     local cframe = CFrame.new(px, py, pz) * CFrame.Angles(rx, ry, rz)
  1956.                     joint.C0 = v0[1] * cframe
  1957.                     joint.C1 = v0[2] * cframe:inverse()
  1958.                 end
  1959.                 RunService.Stepped:wait()
  1960.             end
  1961.         end
  1962.     end
  1963. end
  1964. -- Destruction spell
  1965. do
  1966. GraphicalEffects.destructionSpellSpeed = 5
  1967. GraphicalEffects.destructionSpellEffectSize = 2
  1968. GraphicalEffects.destructionSpellExplosionRate = 10
  1969. GraphicalEffects.destructionSpellFadeDuration = 120
  1970. local partProto = Instance.new("Part")
  1971. local partProtoDecal1 = Instance.new("Decal", partProto)
  1972. local partProtoDecal2 = Instance.new("Decal", partProto)
  1973. local partProtoGyro = Instance.new("BodyGyro", partProto)
  1974. local partProtoPosition = Instance.new("BodyPosition", partProto)
  1975. partProto.CanCollide = false
  1976. partProto.FormFactor = "Custom"
  1977. partProto.Transparency = 1
  1978. partProtoDecal1.Face = "Bottom"
  1979. partProtoDecal1.Texture = "rbxassetid://106508453"
  1980. partProtoDecal2.Face = "Top"
  1981. partProtoDecal2.Texture = "rbxassetid://106508453"
  1982. partProtoGyro.Name = "gyro"
  1983. partProtoGyro.P = 1e6
  1984. partProtoGyro.maxTorque = Vector3.new(1e9, 1e9, 1e9)
  1985. partProtoPosition.Name = "pos"
  1986. partProtoPosition.P = 1e4
  1987. partProtoPosition.maxForce = Vector3.new(1e9, 1e9, 1e9)
  1988. function GraphicalEffects.DestructionSpell(nodes)
  1989.     local destroyTable = {}
  1990.     local regionSizeX, regionSizeY, regionSizeZ
  1991.     local function MagicalDestroyUnchecked(part)
  1992.         local partSize = part.Size
  1993.         if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ then
  1994.             destroyTable[part] = true
  1995.             part.Material = "Plastic"
  1996.             local beginTransparency = part.Transparency
  1997.             local fadeDuration = GraphicalEffects.destructionSpellFadeDuration
  1998.             for i = 1, fadeDuration do
  1999.                 RunService.Stepped:wait()
  2000.                 part.Transparency = beginTransparency + (1 - beginTransparency) * (i / fadeDuration)
  2001.             end
  2002.             pcall(game.Destroy, part)
  2003.             destroyTable[part] = nil
  2004.         end
  2005.     end
  2006.     local function MagicalDestroy(part)
  2007.         if not destroyTable[part] then
  2008.             MagicalDestroyUnchecked(part)
  2009.         end
  2010.     end
  2011.     local function MagicalNodeFinalize(part, gyro, pos, conn)
  2012.         part.Anchored = true
  2013.         pcall(gyro.Destroy, gyro)
  2014.         pcall(pos.Destroy, pos)
  2015.         conn:disconnect()
  2016.     end
  2017.     local model = Instance.new("Model")
  2018.     model.Archivable = false
  2019.     model.Name = "Nolix Wrath"
  2020.     model.Parent = workspace
  2021.     local connections = {}
  2022.     local parts = {}
  2023.     local partsHit = {}
  2024.     local cleanupList = {}
  2025.     local explosionRate = GraphicalEffects.destructionSpellExplosionRate
  2026.     local effectSize = GraphicalEffects.destructionSpellEffectSize
  2027.     partProto.Size = Vector3.new(effectSize, 0.2, effectSize)
  2028.     local speed = GraphicalEffects.destructionSpellSpeed
  2029.     local rateTimer = 0
  2030.     local partRotation = CFrame.Angles(0, 0.5 * math.pi, 0)
  2031.     local minX, minY, minZ, maxX, maxY, maxZ = math.huge, math.huge, math.huge, -math.huge, -math.huge, -math.huge
  2032.     for index = 4, #nodes do
  2033.         local v0, v1, v2, v3 = nodes[index - 3], nodes[index - 2], nodes[index - 1], nodes[index]
  2034.         local p1 = v1
  2035.         local count = math.ceil((v2 - v1).magnitude / effectSize)
  2036.         local linearStep = (v2 - v1) / count
  2037.         for i = 1, count do
  2038.             local alpha = i / count
  2039.             local p2 = GraphicalEffects.CubicInterpolate(v0, v1, v2, v3, alpha)
  2040.             local center = 0.5 * (p1 + p2)
  2041.             local offset = p2 - p1
  2042.             local partId = #parts + 1
  2043.             local hitList = {}
  2044.             partsHit[partId] = hitList
  2045.             local part = partProto:Clone()
  2046.             local gyro = part.gyro
  2047.             local pos = part.pos
  2048.             local cframe = CFrame.new(center, center + offset) * partRotation
  2049.             part.CFrame = cframe
  2050.             gyro.cframe = cframe
  2051.             pos.position = center
  2052.             local posX, posY, posZ = center.X, center.Y, center.Z
  2053.             if posX < minX then minX = posX end
  2054.             if posY < minY then minY = posY end
  2055.             if posZ < minZ then minZ = posZ end
  2056.             if posX > maxX then maxX = posX end
  2057.             if posY > maxY then maxY = posY end
  2058.             if posZ > maxZ then maxZ = posZ end
  2059.             Instance.new("BlockMesh", part).Scale = Vector3.new(offset.magnitude, 0, effectSize)
  2060.             parts[partId] = part
  2061.             destroyTable[part] = true
  2062.             local conn = part.Touched:connect(function(hit)
  2063.                 if not destroyTable[hit] then
  2064.                     hitList[hit] = true
  2065.                 end
  2066.             end)
  2067.             part.Parent = model
  2068.             p1 = p2
  2069.             TaskScheduler.Schedule(0.125, MagicalNodeFinalize, part, gyro, pos, conn)
  2070.             rateTimer = rateTimer + 1
  2071.             while rateTimer >= speed do
  2072.                 RunService.Stepped:wait()
  2073.                 rateTimer = rateTimer - speed
  2074.             end
  2075.         end
  2076.     end
  2077.     local center = Vector3.new(minX + maxX, minY + maxY, minZ + maxZ) * 0.5
  2078.     regionSizeX, regionSizeY, regionSizeZ = maxX - minX, maxY - minY, maxZ - minZ
  2079.     wait(0.5)
  2080.     rateTimer = 0
  2081.     for index, part in pairs(parts) do
  2082.         if index % explosionRate == 1 then
  2083.             local partSize = part.Size
  2084.             if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ then
  2085.                 local explosion = Instance.new("Explosion")
  2086.                 explosion.BlastPressure = 0
  2087.                 local position = part.Position
  2088.                 explosion.BlastRadius = (position - center).magnitude * 0.5
  2089.                 explosion.Position = (position + center) * 0.5
  2090.                 connections[#connections + 1] = explosion.Hit:connect(MagicalDestroy)
  2091.                 explosion.Parent = model
  2092.             end
  2093.         end
  2094.         pcall(part.Destroy, part)
  2095.         destroyTable[part] = nil
  2096.         local hitList = partsHit[index]
  2097.         for hit in pairs(hitList) do
  2098.             local partSize = hit.Size
  2099.             if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ
  2100.                and hit.Parent and not destroyTable[hit] then
  2101.                 TaskScheduler.Start(MagicalDestroyUnchecked, hit)
  2102.                 local explosion = Instance.new("Explosion")
  2103.                 explosion.BlastPressure = 0
  2104.                 explosion.BlastRadius = hit:GetMass() ^ (1 / 3) * 2
  2105.                 explosion.Position = hit.Position
  2106.                 connections[#connections + 1] = explosion.Hit:connect(MagicalDestroy)
  2107.                 explosion.Parent = model
  2108.             end
  2109.         end
  2110.         rateTimer = rateTimer + 1
  2111.         while rateTimer >= 4 * speed do
  2112.             RunService.Stepped:wait()
  2113.             rateTimer = rateTimer - 4 * speed
  2114.         end
  2115.     end
  2116.     wait(0.25)
  2117.     for _, connection in ipairs(connections) do
  2118.         connection:disconnect()
  2119.     end
  2120. end
  2121. end
  2122. -- MainLoop
  2123. function GraphicalEffects.MainLoop()
  2124.     RunService.Stepped:wait()
  2125.     for data in pairs(GraphicalEffects.magicCircleData) do
  2126.         GraphicalEffects.AnimateMagicCircle(data)
  2127.     end
  2128.     for data in pairs(GraphicalEffects.laser_data) do
  2129.         GraphicalEffects.AnimateLaserOfDeath(data)
  2130.     end
  2131.     for data in pairs(GraphicalEffects.missileData) do
  2132.         GraphicalEffects.AnimateMissile(data)
  2133.     end
  2134. end
  2135. TaskScheduler.Start(function()
  2136.     while wait() do
  2137.         GraphicalEffects.MainLoop()
  2138.     end
  2139. end)
  2140.  
  2141. local ChatBubble = {
  2142.     THEME = {
  2143.         AQUA = {
  2144.     Name = "Aqua",
  2145.     Background = Color3.new(0, 1 / 3, 0.5),
  2146.     Foreground = Color3.new(2 / 3, 1, 1)
  2147.         },
  2148.         CLASSIC = {
  2149.     Name = "Classic",
  2150.     Background = Color3.new(0, 0, 0),
  2151.     Foreground = Color3.new(1, 1, 1)
  2152.         },
  2153.         CRIMSON = {
  2154.     Name = "Crimson",
  2155.     Background = Color3.new(0, 0, 0),
  2156.     Foreground = Color3.new(0.9, 0, 0)
  2157.         },
  2158.         GRAPE = {
  2159.     Name = "Grape",
  2160.     Background = Color3.new(0.25, 0, 0.25),
  2161.     Foreground = Color3.new(1, 2 / 3, 1)
  2162.         },
  2163.         LIBERATION = {
  2164.     Name = "Liberation",
  2165.     Background = Color3.new(1 / 6, 3 / 7, 3 / 7),
  2166.     Foreground = Color3.new(1, 1, 1)
  2167.         },
  2168.         PASSION = {
  2169.     Name = "Passion",
  2170.     Background = Color3.new(0.5, 0, 0),
  2171.     Foreground = Color3.new(1, 1, 1)
  2172.         },
  2173.         PURPLE = {
  2174.     Name = "Purple",
  2175.     Background = Color3.new(0.25, 0, 0.25),
  2176.     Foreground = Color3.new(1, 1, 1)
  2177.         },
  2178.         RAINBOW = {
  2179.     Name = "Rainbow",
  2180.     Background = function(bubble_info)
  2181.         local billboard, frame = bubble_info[5], bubble_info[6]
  2182.         TaskScheduler.Start(function()
  2183.             while billboard:IsDescendantOf(workspace) do
  2184.                 local red, green, blue = Utility.GetRainbowRGB(tick())
  2185.                 frame.BackgroundColor3 = Color3.new(0.6 * red, 0.6 * green, 0.65 * blue)
  2186.                 RunService.Stepped:wait()
  2187.             end
  2188.         end)
  2189.     end,
  2190.     Foreground = Color3.new(1, 1, 1)
  2191.         },
  2192.         TEAL = {
  2193.     Name = "Teal",
  2194.     Background = Color3.new(0, 1 / 3, 0.5),
  2195.     Foreground = Color3.new(1, 1, 1)
  2196.         },
  2197.        
  2198.         },
  2199. };
  2200.  
  2201. local FONT_CUSTOM_A_SRC, FONT_CUSTOM_A, TextAlignment, LoadFixedFont, LoadFont, DrawTextNetwork, DrawMultilineTextNetwork, ConfigureChatBubble,
  2202.  
  2203. CreateChatBubble, WrapText, chat_bubbles
  2204. FONT_CUSTOM_A_SRC = "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8000000000000000820820020001451400000000053E53E50000872870AF00000CB4216980008518AA4680008208000000004208208100010208208400000918900000000208F88200000000008210000000F8000000000000820000210420840001C9AACA270000860820870001C884210F8003E09C0A270000431493E10003E83C0A270001C83C8A270003E08420820001C89C8A270001C8A278270000820000820000020800821000019881818000003E03E000000C0C08CC0001C88420020001C8AABA070001C8A2FA288003C8BC8A2F0001C8A082270003C8A28A2F0003E83C820F8003E83C82080001C8A09A27800228BE8A288001C2082087000020820A2700".."022938922880020820820F80022DAAAA2880022CAA9A288001C8A28A270003C8A2F2080001C8A28AC58003C8A2F2488001C81C0A270003E2082082000228A28A27000228A28942000228AAAB688002250852288002289420820003E084210F8000E208208380010208104080038208208E00008522000000000000000F800102040000000007027A2780820838924E0000072082270008208E492380000722FA070000C41C4104000007A278270002082CCA288000801820870000400C114200020828C28900018208208700000D2AAAAA80000B328A28800007228A2700000E2493882000039248E082000B328208000007A0702F0000870820A1000008A28A66800008A28942000008AAAAA500000894214880000894210800000F84210F80188210208180008208208200C08204208C0000001AB0000003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".. "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80".. "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
  2205. FONT_CUSTOM_A = {}
  2206.  
  2207. function ChatBubble.GetTheme()
  2208.     return ChatBubble.theme_info
  2209. end
  2210. function ChatBubble.SetTheme(theme_info)
  2211.     if type(theme_info) == "string" then
  2212.         theme_info = string.lower(theme_info)
  2213.         for key, info in pairs(ChatBubble.THEME) do
  2214.             if info.Name:lower():match(theme_info) then
  2215.                 ChatBubble.SetTheme(info)
  2216.                 break
  2217.             end
  2218.         end
  2219.         return
  2220.     end
  2221.     ChatBubble.theme_info = theme_info
  2222.     ChatBubble.background_color = theme_info.Background
  2223.     ChatBubble.font = LoadFont(ChatBubble.FONT_DEFAULT, theme_info.Foreground)
  2224. end
  2225.  
  2226. do
  2227. local floor = math.floor
  2228. local max = math.max
  2229. local asc = string.byte
  2230. local chr = string.char
  2231. local find = string.find
  2232. local gmatch = string.gmatch
  2233. local sub = string.sub
  2234. local insert = table.insert
  2235. local type = type
  2236. local unpack = unpack
  2237.  
  2238. local PopIntegerBit
  2239.  
  2240. TextAlignment = setmetatable({
  2241.     [0] = 0,
  2242.     [1] = 1,
  2243.     [2] = 2,
  2244.     Left = 0,
  2245.     Center = 1,
  2246.     Right = 2
  2247. }, {
  2248.     __call = function(self, ...)
  2249.         local argc = #{...}
  2250.         if argc == 0 then
  2251.             return 0
  2252.         else
  2253.             local arg = (...)
  2254.             local value = rawget(self, arg)
  2255.             if value then
  2256.                 return value
  2257.             else
  2258.                 local arg_type = type(arg)
  2259.                 error("Invalid value" .. ((arg_type == "number") and (" " .. arg) or ((arg_type == "string") and (" \"" .. arg .. "\"") or
  2260.  
  2261. "")) .. " for enum TextAlignment")
  2262.             end
  2263.         end
  2264.     end
  2265. })
  2266.  
  2267. function PopIntegerBit(value, bit)
  2268.     if value >= bit then
  2269.         return 1, value - bit
  2270.     else
  2271.         return 0, value
  2272.     end
  2273. end
  2274. function LoadFixedFont(dest, src, height, width)
  2275.     local n = #src / 64 - 1
  2276.     local bit_index = 0
  2277.     local symbol_bits = width * height
  2278.     for i = 0, 255 do
  2279.         local char_data = {}
  2280.         for j = 1, height do
  2281.             char_data[j] = {}
  2282.         end
  2283.         dest[i] = char_data
  2284.     end
  2285.     for i = 1, #src do
  2286.         local buffer = tonumber(sub(src, i, i), 16)
  2287.         for j = 1, 4 do
  2288.             local code = floor(bit_index / symbol_bits)
  2289.             local row = floor(bit_index / width) % height + 1
  2290.             local column = bit_index % width + 1
  2291.             dest[code][row][column], buffer = PopIntegerBit(buffer, 8)
  2292.             buffer = buffer * 2
  2293.             bit_index = bit_index + 1
  2294.         end
  2295.     end
  2296. end
  2297. function LoadFont(font_data, color)
  2298.     local font_obj = {}
  2299.     for character, char_data in pairs(font_data) do
  2300.         local code = character
  2301.         if type(code) ~= "number" then
  2302.             code = asc(character)
  2303.         end
  2304.         local height = #char_data
  2305.         local width = #char_data[1]
  2306.         local pixel_h = 1 / height
  2307.         local pixel_w = 1 / width
  2308.         local pixel_size = UDim2.new(pixel_w, 0, pixel_h, 0)
  2309.         local frame = Instance.new("Frame")
  2310.         frame.BackgroundTransparency = 1
  2311.         frame.Name = ""
  2312.         for y = 1, height do
  2313.             local row = char_data[y]
  2314.             for x = 1, width do
  2315.                 local opacity = row[x]
  2316.                 if opacity ~= 0 then
  2317.                     local pixel = Instance.new("Frame", frame)
  2318.                     pixel.BackgroundColor3 = color
  2319.                     pixel.BorderSizePixel = 0
  2320.                     pixel.Name = ""
  2321.                     pixel.Position = UDim2.new(x * pixel_w, 0, y * pixel_h, 0) - pixel_size
  2322.                     pixel.Size = pixel_size -- + UDim2.new(0, 0, 0, 1) -- correction
  2323.                     -- ^ never mind that correction, fixed by changing font size to 12x16 instead of 13x17
  2324.                     if opacity then
  2325.                         pixel.BackgroundTransparency = 1 - opacity
  2326.                     end
  2327.                 end
  2328.             end
  2329.         end
  2330.         font_obj[code] = {frame, height, width}
  2331.     end
  2332.     return font_obj
  2333. end
  2334. function DrawTextNetwork(text, font, size, delay_offset)
  2335.     if #text == 0 then
  2336.         text = " "
  2337.     end
  2338.     local frame = Instance.new("Frame")
  2339.     frame.BackgroundTransparency = 1
  2340.     frame.BorderSizePixel = 0
  2341.     local objects = {}
  2342.     local length = #text
  2343.     local height = 0
  2344.     local width = 0
  2345.     for i = 1, length do
  2346.         local character = sub(text, i, i)
  2347.         local code = asc(character)
  2348.         local char_data = assert(font[code] or "FONT_SYMBOL_MISSING", "FONT ERROR: '" .. character .. "' (" .. code .. ") not found")
  2349.         local char_proto, char_h, char_w = unpack(char_data)
  2350.         objects[i] = char_data
  2351.         height = max(char_h, height)
  2352.         width = width + char_w
  2353.     end
  2354.     local offset = 0
  2355.     local punctuation_delay = 0
  2356.     for i = 1, length do
  2357.         delay(delay_offset + (i + punctuation_delay - 1) / 30, function()
  2358.             local char_data = objects[i]
  2359.             local char_proto, char_h, char_w = unpack(char_data)
  2360.             local char_obj = char_proto:Clone()
  2361.             char_obj.Position = UDim2.new(offset / width, 0, 0, 0)
  2362.             char_obj.Size = UDim2.new(char_w / width, 0, 1, 0)
  2363.             char_obj.Parent = frame
  2364.             offset = offset + char_w
  2365.         end)
  2366.         local character = sub(text, i, i)
  2367.         if character == "." then
  2368.             punctuation_delay = punctuation_delay + 3
  2369.         elseif character == "?" or character == "!" then
  2370.             punctuation_delay = punctuation_delay + 2
  2371.         elseif character == ";" or character == "~" then
  2372.             punctuation_delay = punctuation_delay + 1
  2373.         end
  2374.     end
  2375.     local ratio = (height == 0) and (0) or (width / height)
  2376.     frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale, size.Y.Offset)
  2377.     return frame, height, width, (length + punctuation_delay) / 30
  2378. end
  2379. function DrawMultilineTextNetwork(text, font, size, delay_offset, ...)
  2380.     local align = TextAlignment(...)
  2381.     local frame = Instance.new("Frame")
  2382.     frame.BackgroundTransparency = 1
  2383.     frame.BorderSizePixel = 0
  2384.     local height = 0
  2385.     local width = 0
  2386.     local objects = {}
  2387.     for line in gmatch(text .. "\n", "([^\n]*)\n") do
  2388.         local line_obj, line_h, line_w, line_delay = DrawTextNetwork(line, font, size, delay_offset)
  2389.         insert(objects, {line_obj, line_h, line_w})
  2390.         height = height + line_h
  2391.         width = max(line_w, width)
  2392.         delay_offset = delay_offset + line_delay
  2393.     end
  2394.     local offset = 0
  2395.     for index, line_data in ipairs(objects) do
  2396.         local line_obj, line_h, line_w = unpack(line_data)
  2397.         local align_offset
  2398.         if align == TextAlignment.Left then
  2399.             align_offset = 0
  2400.         elseif align == TextAlignment.Center then
  2401.             align_offset = 0.5 - line_w / width / 2
  2402.         elseif align == TextAlignment.Right then
  2403.             align_offset = 1 - line_w / width
  2404.         end
  2405.         line_obj.Position = UDim2.new(align_offset, 0, offset / height, 0)
  2406.         line_obj.Parent = frame
  2407.         offset = offset + line_h
  2408.     end
  2409.     local line_count = #objects
  2410.     local ratio = (height == 0) and (0) or (line_count * width / height)
  2411.     frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale * line_count, size.Y.Offset * line_count)
  2412.     return frame, height, width
  2413. end
  2414. end
  2415.  
  2416. LoadFixedFont(FONT_CUSTOM_A, FONT_CUSTOM_A_SRC, 8, 6)
  2417. ChatBubble.FONT_DEFAULT = FONT_CUSTOM_A
  2418. ChatBubble.SetTheme("Classic")
  2419.  
  2420. chat_bubbles = {}
  2421.  
  2422. function CreateChatBubble(bubble_info)
  2423.     local creation_time, text, backup = bubble_info[1], bubble_info[2], bubble_info[8]
  2424.     local billboard, frame, label
  2425.     if backup and false then
  2426.         billboard = backup:Clone()
  2427.         frame = billboard.Frame
  2428.         label = frame.Label
  2429.         bubble_info[5] = billboard
  2430.         bubble_info[6] = frame
  2431.         bubble_info[7] = label
  2432.         billboard.Parent = workspace
  2433.     else
  2434.         label = DrawMultilineTextNetwork(text, bubble_info[9], UDim2.new(0, 12, 0, 16), creation_time - time(), "Center")
  2435.         label.Name = "Label"
  2436.         label.Position = UDim2.new(0, 16, 0, 16)
  2437.         billboard = Instance.new("BillboardGui", workspace)
  2438.         billboard.Adornee = chatAdornee
  2439.         billboard.AlwaysOnTop = true
  2440.         billboard.Size = UDim2.new(label.Size.X.Scale, label.Size.X.Offset + 32, label.Size.Y.Scale, label.Size.Y.Offset + 32)
  2441.         billboard.SizeOffset = Vector2.new(0, 0)
  2442.         billboard.StudsOffset = Vector3.new(0, 1, 0)
  2443.         frame = Instance.new("Frame", billboard)
  2444.         bubble_info[5] = billboard
  2445.         bubble_info[6] = frame
  2446.         bubble_info[7] = label
  2447.         local background_color = bubble_info[10]
  2448.         if type(background_color) == "function" then
  2449.             background_color(bubble_info)
  2450.         else
  2451.             frame.BackgroundColor3 = background_color
  2452.         end
  2453.         frame.BackgroundTransparency = 0.3
  2454.         frame.BorderSizePixel = 0
  2455.         frame.ClipsDescendants = true
  2456.         frame.Name = "Frame"
  2457.         frame.Size = UDim2.new(1, 0, 0, 0)
  2458.         label.Parent = frame
  2459.         -- bubble_info[8] = billboard:Clone()
  2460.     end
  2461. end
  2462. local tween_time = 0.3
  2463. function ConfigureChatBubble(bubble_info)
  2464.     local creation_time, destruction_time, billboard, frame = bubble_info[1], bubble_info[3], bubble_info[5], bubble_info[6]
  2465.     if not billboard or billboard.Parent ~= workspace then
  2466.         CreateChatBubble(bubble_info)
  2467.         billboard, frame = bubble_info[5], bubble_info[6]
  2468.     end
  2469.     if billboard.Adornee ~= chatAdornee then
  2470.         billboard.Adornee = chatAdornee
  2471.     end
  2472.     local current_time = time()
  2473.     local elapsed_time = current_time - creation_time
  2474.     local remaining_time = destruction_time - current_time
  2475.     if remaining_time < 0 then
  2476.         bubble_info[4] = false
  2477.         billboard:Destroy()
  2478.         return false
  2479.     elseif remaining_time < tween_time then
  2480.         local tween_progress = math.sin(remaining_time * math.pi / (tween_time * 2))
  2481.         frame.Size = UDim2.new(1, 0, tween_progress, 0)
  2482.     elseif elapsed_time < tween_time then
  2483.         local tween_progress = math.sin(elapsed_time * math.pi / (tween_time * 2))
  2484.         frame.Size = UDim2.new(1, 0, tween_progress, 0)
  2485.     elseif frame.Size ~= UDim2.new(1, 0, 1, 0) then
  2486.         frame.Size = UDim2.new(1, 0, 1, 0)
  2487.     end
  2488.     return true
  2489. end
  2490. function ChatBubble.MainLoop()
  2491.     local offset = 0
  2492.     local removing = {}
  2493.     for index, bubble_info in ipairs(chat_bubbles) do
  2494.         if not ConfigureChatBubble(bubble_info) then
  2495.             removing[#removing + 1] = index - #removing
  2496.         else
  2497.             local billboard, frame = bubble_info[5], bubble_info[6]
  2498.             local billboard_h = billboard.Size.Y.Offset
  2499.             local bubble_h = frame.Size.Y.Scale * billboard_h
  2500.             offset = 8 + offset + bubble_h
  2501.             billboard.SizeOffset = Vector2.new(0, offset / billboard_h - 0.5)
  2502.         end
  2503.     end
  2504.     for index, bubble_index in ipairs(removing) do
  2505.         table.remove(chat_bubbles, bubble_index)
  2506.     end
  2507.     RunService.Stepped:wait()
  2508. end
  2509. function WrapText(text, character_limit, line_length_limit)
  2510.     if #text > character_limit then
  2511.         text = string.sub(text, 1, character_limit - 3) .. "..."
  2512.     end
  2513.     local text_length = #text
  2514.     local line_length = 0
  2515.     local i = 0
  2516.     while i <= text_length do
  2517.         i = i + 1
  2518.         local character = string.sub(text, i, i)
  2519.         if character == "\t" then
  2520.             local tabulation_size = 4 - line_length % 4
  2521.             line_length = line_length + tabulation_size
  2522.             if line_length >= line_length_limit then
  2523.                 tabulation_size = line_length - line_length_limit
  2524.                 line_length = 0
  2525.                 text_length = text_length + tabulation_size
  2526.                 text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. "\n" .. string.sub(text, i + 1)
  2527.                 i = i + tabulation_size + 1
  2528.             else
  2529.                 text_length = text_length + tabulation_size - 1
  2530.                 text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. string.sub(text, i + 1)
  2531.                 i = i + tabulation_size - 1
  2532.             end
  2533.         elseif character == "\n" then
  2534.             line_length = 0
  2535.         else
  2536.             line_length = line_length + 1
  2537.             if line_length >= line_length_limit then
  2538.                 local k = i - line_length + 1
  2539.                 local success = false
  2540.                 for j = i, k, -1 do
  2541.                     if string.match(string.sub(text, j, j), "[ \t]") then
  2542.                         text = string.sub(text, 1, j - 1) .. "\n" .. string.sub(text, j + 1)
  2543.                         text_length = text_length + 1
  2544.                         success = true
  2545.                         break
  2546.                     end
  2547.                 end
  2548.                 if not success then
  2549.                     text = string.sub(text, 1, i) .. "\n" .. string.sub(text, i + 1)
  2550.                     text_length = text_length + 1
  2551.                 end
  2552.                 i = i + 1
  2553.                 line_length = 0
  2554.             end
  2555.         end
  2556.     end
  2557.     if #text > character_limit then
  2558.         text = string.sub(text, 1, character_limit - 3) .. "..."
  2559.     end
  2560.     return text
  2561. end
  2562. function ChatBubble.Create(text, theme)
  2563.     local text = WrapText(text, 200, 30)
  2564.     local creation_time = time()
  2565.     local bubble_info = {creation_time, text, creation_time + 6 + #text / 15, true}
  2566.     local previousTheme
  2567.     if theme then
  2568.         previousTheme = ChatBubble.GetTheme()
  2569.         ChatBubble.SetTheme(theme)
  2570.     end
  2571.     bubble_info[9] = ChatBubble.font
  2572.     bubble_info[10] = ChatBubble.background_color
  2573.     if previousTheme then
  2574.         ChatBubble.SetTheme(previousTheme)
  2575.     end
  2576.     table.insert(chat_bubbles, 1, bubble_info)
  2577. end
  2578. TaskScheduler.Start(function()
  2579.     while wait() do
  2580.         ChatBubble.MainLoop()
  2581.     end
  2582. end)
  2583. local PlayerControl = {};
  2584.  
  2585. PlayerControl.fly_acceleration = 10
  2586. PlayerControl.fly_basespeed = 250
  2587. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  2588. PlayerControl.featherfallEnabled = true
  2589. PlayerControl.pushable = false
  2590. PlayerControl.rolling = false
  2591. PlayerControl.rollingAngle = 0
  2592. PlayerControl.rollingOffset = 0
  2593. PlayerControl.rollingMaxOffset = 3
  2594. PlayerControl.rollingSpeed = 1 / 50
  2595. PlayerControl.characterEnabled = false
  2596. PlayerControl.characterMode = "normal"
  2597. local character = nil
  2598. local flying, flyingMomentum, flyingTilt = false, Vector3.new(), 0
  2599. local pose, regeneratingHealth, jumpDebounce = "Standing", false, false
  2600. -- TODO: make local variables public
  2601. local model, bodyColors, leftArmMesh, leftLegMesh, rightArmMesh, rightLegMesh, torsoMesh, wildcardHat, wildcardHandle, wildcardMesh, pants, shirt, humanoid,
  2602.  
  2603. head, leftArm, leftLeg, rightArm, rightLeg, torso, rootPart, rootJoint, face, soundFreeFalling, soundGettingUp, soundRunning, leftHip, leftShoulder,
  2604.  
  2605. rightHip, rightShoulder, neck, wildcardWeld, feetPart, feetWeld, feetTouchInterest, bodyGyro, bodyVelocity, headMesh, torsoLight
  2606. local AnimateCharacter
  2607. local chatBubbles = {}
  2608. local chatCharacterLimit = 240
  2609. function PlayerControl.Chat(message)
  2610.     ChatBubble.Create(tostring(message))
  2611. end
  2612. function PlayerControl.CreateCharacter()
  2613.     local characterMode = PlayerControl.characterMode
  2614.     if characterMode == "normal" then
  2615.         if not PlayerControl.characterEnabled then
  2616.             return
  2617.         end
  2618.         local active = true
  2619.         local torsoCFrame = (torso and torso.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2620.         if torsoCFrame.p.Y < -450 then
  2621.             torsoCFrame = CFrame.new(0, 10, 0)
  2622.         end
  2623.         local rootPartCFrame = (rootPart and rootPart.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2624.         if rootPartCFrame.p.Y < -450 then
  2625.             rootPartCFrame = CFrame.new(0, 10, 0)
  2626.         end
  2627.         local cameraCFrame = Camera.CoordinateFrame
  2628.         local connections = {}
  2629.         local feetTouching = {}
  2630.         local previousWalkSpeed = 0
  2631.         local prevLeftHip, prevLeftShoulder, prevRightHip, prevRightShoulder = leftHip, leftShoulder, rightHip, rightShoulder
  2632.         model = Instance.new("Model")
  2633.         humanoid = Instance.new("Humanoid", model)
  2634.         head = Instance.new("Part", model)
  2635.         leftArm = Instance.new("Part", model)
  2636.         leftLeg = Instance.new("Part", model)
  2637.         rightArm = Instance.new("Part", model)
  2638.         rightLeg = Instance.new("Part", model)
  2639.         torso = Instance.new("Part", model)
  2640.         rootPart = Instance.new("Part", model)
  2641.         local soundFallingDown = Instance.new("Sound", head)
  2642.         soundFreeFalling = Instance.new("Sound", head)
  2643.         soundGettingUp = Instance.new("Sound", head)
  2644.         local soundJumping = Instance.new("Sound", head)
  2645.         soundRunning = Instance.new("Sound", head)
  2646.         leftHip = Instance.new("Motor", torso)
  2647.         leftShoulder = Instance.new("Motor", torso)
  2648.         rightHip = Instance.new("Motor", torso)
  2649.         rightShoulder = Instance.new("Motor", torso)
  2650.         neck = Instance.new("Motor", torso)
  2651.         rootJoint = Instance.new("Motor", rootPart)
  2652.         feetPart = Instance.new("Part", model)
  2653.         feetWeld = Instance.new("Weld", torso)
  2654.         bodyGyro = Instance.new("BodyGyro", rootPart)
  2655.         bodyVelocity = Instance.new("BodyVelocity", rootPart)
  2656.         model.Archivable = false
  2657.         model.Name = "U_M9"
  2658.         model.PrimaryPart = head
  2659.         humanoid.LeftLeg = leftLeg
  2660.         humanoid.RightLeg = rightLeg
  2661.         humanoid.Torso = rootPart
  2662.         head.CFrame = torsoCFrame * CFrame.new(0, 1.5, 0)
  2663.         head.FormFactor = "Symmetric"
  2664.         head.Locked = true
  2665.         head.Name = "Head"
  2666.         head.Size = Vector3.new(2, 1, 1)
  2667.         head.TopSurface = "Smooth"
  2668.         leftArm.CanCollide = false
  2669.         leftArm.CFrame = torsoCFrame * CFrame.new(-1.5, 0, 0)
  2670.         leftArm.FormFactor = "Symmetric"
  2671.         leftArm.Locked = true
  2672.         leftArm.Name = "Left Arm"
  2673.         leftArm.Size = Vector3.new(1, 2, 1)
  2674.         leftLeg.BottomSurface = "Smooth"
  2675.         leftLeg.CanCollide = false
  2676.         leftLeg.CFrame = torsoCFrame * CFrame.new(-0.5, -2, 0)
  2677.         leftLeg.FormFactor = "Symmetric"
  2678.         leftLeg.Locked = true
  2679.         leftLeg.Name = "Left Leg"
  2680.         leftLeg.Size = Vector3.new(1, 2, 1)
  2681.         leftLeg.TopSurface = "Smooth"
  2682.         rightArm.CanCollide = false
  2683.         rightArm.CFrame = torsoCFrame * CFrame.new(1.5, 0, 0)
  2684.         rightArm.FormFactor = "Symmetric"
  2685.         rightArm.Locked = true
  2686.         rightArm.Name = "Right Arm"
  2687.         rightArm.Size = Vector3.new(1, 2, 1)
  2688.         rightLeg.BottomSurface = "Smooth"
  2689.         rightLeg.CanCollide = false
  2690.         rightLeg.CFrame = torsoCFrame * CFrame.new(0.5, -2, 0)
  2691.         rightLeg.FormFactor = "Symmetric"
  2692.         rightLeg.Locked = true
  2693.         rightLeg.Name = "Right Leg"
  2694.         rightLeg.Size = Vector3.new(1, 2, 1)
  2695.         rightLeg.TopSurface = "Smooth"
  2696.         torso.CFrame = torsoCFrame
  2697.         torso.FormFactor = "Symmetric"
  2698.         torso.LeftSurface = "Weld"
  2699.         torso.Locked = true
  2700.         torso.RightSurface = "Weld"
  2701.         torso.Name = "Torso"
  2702.         torso.Size = Vector3.new(2, 2, 1)
  2703.         rootPart.BottomSurface = "Smooth"
  2704.         rootPart.BrickColor = BrickColor.Blue()
  2705.         rootPart.CFrame = rootPartCFrame
  2706.         rootPart.FormFactor = "Symmetric"
  2707.         rootPart.LeftSurface = "Weld"
  2708.         rootPart.Locked = true
  2709.         rootPart.RightSurface = "Weld"
  2710.         rootPart.Name = "HumanoidRootPart"
  2711.         rootPart.Size = Vector3.new(2, 2, 1)
  2712.         rootPart.TopSurface = "Smooth"
  2713.         rootPart.Transparency = 1
  2714.         soundFreeFalling.Archivable = false
  2715.         soundFreeFalling.SoundId = "rbxasset://sounds/swoosh.wav"
  2716.         soundGettingUp.Archivable = false
  2717.         soundGettingUp.SoundId = "rbxasset://sounds/hit.wav"
  2718.         soundRunning.Archivable = false
  2719.         soundRunning.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
  2720.         soundRunning.Looped = true
  2721.         leftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2722.         leftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2723.         leftHip.MaxVelocity = 0.1
  2724.         leftHip.Name = "Left Hip"
  2725.         leftHip.Part0 = torso
  2726.         leftHip.Part1 = leftLeg
  2727.         leftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2728.         leftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2729.         leftShoulder.MaxVelocity = 0.15
  2730.         leftShoulder.Name = "Left Shoulder"
  2731.         leftShoulder.Part0 = torso
  2732.         leftShoulder.Part1 = leftArm
  2733.         rightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2734.         rightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2735.         rightHip.MaxVelocity = 0.1
  2736.         rightHip.Name = "Right Hip"
  2737.         rightHip.Part0 = torso
  2738.         rightHip.Part1 = rightLeg
  2739.         rightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2740.         rightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2741.         rightShoulder.MaxVelocity = 0.15
  2742.         rightShoulder.Name = "Right Shoulder"
  2743.         rightShoulder.Part0 = torso
  2744.         rightShoulder.Part1 = rightArm
  2745.         if prevLeftHip then
  2746.             leftHip.CurrentAngle = prevLeftHip.CurrentAngle
  2747.             leftHip.DesiredAngle = prevLeftHip.DesiredAngle
  2748.         end
  2749.         if prevLeftShoulder then
  2750.             leftShoulder.CurrentAngle = prevLeftShoulder.CurrentAngle
  2751.             leftShoulder.DesiredAngle = prevLeftShoulder.DesiredAngle
  2752.         end
  2753.         if prevRightHip then
  2754.             rightHip.CurrentAngle = prevRightHip.CurrentAngle
  2755.             rightHip.DesiredAngle = prevRightHip.DesiredAngle
  2756.         end
  2757.         if prevRightShoulder then
  2758.             rightShoulder.CurrentAngle = prevRightShoulder.CurrentAngle
  2759.             rightShoulder.DesiredAngle = prevRightShoulder.DesiredAngle
  2760.         end
  2761.         neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2762.         neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2763.         neck.Name = "Neck"
  2764.         neck.Part0 = torso
  2765.         neck.Part1 = head
  2766.         rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2767.         rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2768.         rootJoint.Name = "RootJoint"
  2769.         rootJoint.Part0 = rootPart
  2770.         rootJoint.Part1 = torso
  2771.         feetPart.BottomSurface = "Smooth"
  2772.         feetPart.CanCollide = false
  2773.         feetPart.CFrame = torsoCFrame * CFrame.new(0, -3.1, 0)
  2774.         feetPart.FormFactor = "Custom"
  2775.         feetPart.Locked = true
  2776.         feetPart.Name = "Platform"
  2777.         feetPart.Size = Vector3.new(1.8, 0.2, 0.8)
  2778.         feetPart.TopSurface = "Smooth"
  2779.         feetPart.Transparency = 1
  2780.         feetWeld.C0 = CFrame.new(0, -3, 0)
  2781.         feetWeld.C1 = CFrame.new(0, 0.1, 0)
  2782.         feetWeld.Name = "PlatformWeld"
  2783.         feetWeld.Part0 = torso
  2784.         feetWeld.Part1 = feetPart
  2785.         table.insert(connections, feetPart.Touched:connect(function(hit)
  2786.             feetTouching[hit] = true
  2787.         end))
  2788.         table.insert(connections, feetPart.TouchEnded:connect(function(hit)
  2789.             feetTouching[hit] = nil
  2790.         end))
  2791.         feetTouchInterest = feetPart:FindFirstChild("TouchInterest")
  2792.         bodyGyro.D = 3250
  2793.         bodyGyro.P = 400000
  2794.         bodyGyro.maxTorque = Vector3.new(1000000000, 0, 1000000000)
  2795.         bodyVelocity.P = 5000
  2796.         bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  2797.         bodyVelocity.velocity = Vector3.new(0, 0, 0)
  2798.         torsoLight = Instance.new("PointLight", torso)
  2799.         torsoLight.Brightness = 0.4
  2800.         torsoLight.Color = Color3.new(1, 1, 1)
  2801.         torsoLight.Range = 16
  2802.         torsoLight.Shadows = true
  2803.         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)
  2804.         local forcefields = {[ff1] = head, [ff2] = leftArm, [ff3] = leftLeg, [ff4] = rightArm, [ff5] = rightLeg, [ff6] = torso, [ff7] = wildcardHandle, [ff8] = feetPart, [ff9] = rootPart}
  2805.         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}    
  2806.    
  2807.        
  2808.         local facePresent = false
  2809.         local headMeshPresent = false
  2810.  
  2811.        
  2812.         if not facePresent then
  2813.             local face = Instance.new("Decal", head)
  2814.             face.Texture = "rbxasset://textures/face.png"
  2815.             objects[face] = true
  2816.         end
  2817.         if not headMeshPresent then
  2818.             local headMesh = Instance.new("SpecialMesh", head)
  2819.             headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  2820.             objects[headMesh] = true
  2821.         end
  2822.         table.insert(connections, model.DescendantAdded:connect(function(object)
  2823.             local success, is_localscript = pcall(game.IsA, object, "LocalScript")
  2824.             if success and is_localscript then
  2825.                 pcall(Utility.SetProperty, object, "Disabled", true)
  2826.                 local changed_connection = pcall(object.Changed.connect, object.Changed, function(property)
  2827.                     if property == "Disabled" and not object.Disabled then
  2828.                         pcall(Utility.SetProperty, object, "Disabled", true)
  2829.                         object:Destroy()
  2830.                     end
  2831.                 end)
  2832.             end
  2833.             if not objects[object] then
  2834.                 object:Destroy()
  2835.             end
  2836.         end))
  2837.         model.Parent = workspace
  2838.         Player.Character = model
  2839.         Camera.CameraSubject = humanoid
  2840.         Camera.CameraType = "Track"
  2841.         Camera.CoordinateFrame = cameraCFrame
  2842.         local IsStanding
  2843.         local RegenerateHealth
  2844.         local ResetCharacter
  2845.         function IsStanding()
  2846.             return not not next(feetTouching)
  2847.         end
  2848.         function RegenerateHealth()
  2849.             if humanoid.Health < 1 then
  2850.                 humanoid.Health = 100
  2851.             elseif not regeneratingHealth then
  2852.                 regeneratingHealth = true
  2853.                 local elapsedTime = wait(1)
  2854.                 regeneratingHealth = false
  2855.                 if humanoid.Health < 100 then
  2856.                     humanoid.Health = math.min(humanoid.Health + elapsedTime, 100)
  2857.                 end
  2858.             end
  2859.         end
  2860.         function ResetCharacter()
  2861.             for index, connection in ipairs(connections) do
  2862.                 connection:disconnect()
  2863.             end
  2864.             active = false
  2865.         end
  2866.         table.insert(connections, model.AncestryChanged:connect(ResetCharacter))
  2867.         table.insert(connections, model.DescendantRemoving:connect(function(object)
  2868.             local parent = forcefields[object]
  2869.             if parent then
  2870.                 forcefields[object] = nil
  2871.                 local new_forcefield = Instance.new("ForceField")
  2872.                 forcefields[new_forcefield] = parent
  2873.                 objects[new_forcefield] = true
  2874.                 new_forcefield.Parent = parent
  2875.             elseif objects[object] then
  2876.                 ResetCharacter()
  2877.             end
  2878.         end))
  2879.         table.insert(connections, humanoid.HealthChanged:connect(RegenerateHealth))
  2880.         table.insert(connections, humanoid.Climbing:connect(function() pose = "Climbing" end))
  2881.         table.insert(connections, humanoid.FallingDown:connect(function(state)  pose = "FallingDown" end))
  2882.         table.insert(connections, humanoid.FreeFalling:connect(function(state) pose = "FreeFall" if state then soundFreeFalling:Play() else soundFreeFalling:Pause() end end))
  2883.         table.insert(connections, humanoid.GettingUp:connect(function(state) pose = "GettingUp" if state then soundGettingUp:Play() else soundGettingUp:Pause() end end))
  2884.         table.insert(connections, humanoid.PlatformStanding:connect(function() pose = "PlatformStanding" end))
  2885.         table.insert(connections, humanoid.Seated:connect(function() pose = "Seated" end))
  2886.         table.insert(connections, humanoid.Swimming:connect(function(speed) if speed > 0 then pose = "Swimming" else pose = "Standing" end end))
  2887.         local previousRootPartCFrame = rootPart.CFrame
  2888.         for i,v in next, model:GetChildren() do
  2889.             if v:IsA"BasePart" then
  2890.             v.Material = "Glass"
  2891.             v.BrickColor = BrickColor.new("Institutional white")
  2892.             end
  2893.         end
  2894.         TaskScheduler.Start(function()
  2895.             while active do
  2896.                 local totalTime = TaskScheduler.GetCurrentTime()
  2897.                 local stepTime = 1 / 60
  2898.                 if not PlayerControl.characterEnabled then
  2899.                     ResetCharacter()
  2900.                     break
  2901.                 end
  2902.                 torsoLight.Brightness = 0.5 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
  2903.                 spawn(function()
  2904.                     for i,v in next, model:GetChildren() do
  2905.             if v:IsA"BasePart" then
  2906.             v.Transparency = 0.1 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
  2907.             end
  2908.         end
  2909.                 end)
  2910.                 local featherfallEnabled = PlayerControl.IsFeatherfallEnabled()
  2911.                 local rootPartCFrame = rootPart.CFrame
  2912.                 if not jumpDebounce and UserInterface:IsKeyDown(Enum.KeyCode.Space) then
  2913.                     if humanoid.Sit then
  2914.                         humanoid.Sit = false
  2915.                     end
  2916.                     if IsStanding() then
  2917.                         jumpDebounce = true
  2918.                         pose = "Jumping"
  2919.                         rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 50, rootPart.Velocity.Z)
  2920.                         torso.Velocity = Vector3.new(torso.Velocity.X, 50, torso.Velocity.Z)                       
  2921.                         TaskScheduler.Schedule(1, function()
  2922.                             if pose == "Jumping" then
  2923.                                 pose = "FreeFall"
  2924.                             end
  2925.                             jumpDebounce = false
  2926.                             humanoid.Jump = false
  2927.                         end)
  2928.                     end
  2929.                 end
  2930.                 local cameraCFrame = Camera.CoordinateFrame
  2931.                 local cameraDirection = cameraCFrame.lookVector
  2932.                 if flying then
  2933.                     if PlayerControl.rolling then
  2934.                         local rootPartCFrame = rootPart.CFrame
  2935.                         local speed = (rootPartCFrame - rootPartCFrame.p):pointToObjectSpace(rootPart.Velocity).Y
  2936.                         local decay = 0.5 ^ stepTime
  2937.                         if math.abs(speed) <= 50 then
  2938.                             PlayerControl.rollingAngle = (((PlayerControl.rollingAngle + 0.5) % 1 - 0.5) * decay) % 1
  2939.                             PlayerControl.rollingOffset = PlayerControl.rollingOffset * decay
  2940.                         else
  2941.                             PlayerControl.rollingAngle = (PlayerControl.rollingAngle + stepTime * speed * PlayerControl.rollingSpeed) % 1
  2942.                             PlayerControl.rollingOffset = (PlayerControl.rollingOffset + PlayerControl.rollingMaxOffset * (1 / decay - 1)) * decay
  2943.                         end
  2944.                         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)
  2945.                     else
  2946.                         rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2947.                         PlayerControl.rollingAngle = 0
  2948.                         PlayerControl.rollingOffset = 0
  2949.                     end
  2950.                     rightShoulder.MaxVelocity = 0.5
  2951.                     leftShoulder.MaxVelocity = 0.5
  2952.                     rightShoulder.DesiredAngle = 0
  2953.                     leftShoulder.DesiredAngle = 0
  2954.                     rightHip.DesiredAngle = 0
  2955.                     leftHip.DesiredAngle = 0
  2956.                     bodyGyro.D = 500
  2957.                     bodyGyro.P = 1e6
  2958.                     bodyGyro.maxTorque = Vector3.new(1e6, 1e6, 1e6)
  2959.                     bodyVelocity.P = 1250
  2960.                     bodyVelocity.maxForce = Vector3.new(1e6, 1e6, 1e6)
  2961.                     local movementRight = 0
  2962.                     local movementForward = 0
  2963.                     local movementUp = 0
  2964.                     if UserInterface:IsKeyDown(Enum.KeyCode.A) and not UserInterface:IsKeyDown(Enum.KeyCode.D) then
  2965.                         movementRight = -1
  2966.                     elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  2967.                         movementRight = 1
  2968.                     end
  2969.                     if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  2970.                         movementUp = 0.2
  2971.                         if not UserInterface:IsKeyDown(Enum.KeyCode.S) then
  2972.                             movementForward = -1
  2973.                         end
  2974.                     elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  2975.                         movementForward = 1
  2976.                     end
  2977.                     local movement = PlayerControl.fly_acceleration * cameraCFrame:vectorToWorldSpace(Vector3.new(movementRight, movementUp, movementForward))
  2978.                     local previousMomentum = flyingMomentum
  2979.                     local previousTilt = flyingTilt
  2980.                     flyingMomentum = movement + flyingMomentum * (1 - PlayerControl.fly_acceleration / PlayerControl.fly_speed)
  2981.                     flyingTilt = ((flyingMomentum * Vector3.new(1, 0, 1)).unit:Cross((previousMomentum * Vector3.new(1, 0, 1)).unit)).Y
  2982.                     if flyingTilt ~= flyingTilt or flyingTilt == math.huge then
  2983.                         flyingTilt = 0
  2984.                     end
  2985.                     local absoluteTilt = math.abs(flyingTilt)
  2986.                     if absoluteTilt > 0.06 or absoluteTilt < 0.0001 then
  2987.                         if math.abs(previousTilt) > 0.0001 then
  2988.                             flyingTilt = previousTilt * 0.9
  2989.                         else
  2990.                             flyingTilt = 0
  2991.                         end
  2992.                     else
  2993.                         flyingTilt = previousTilt * 0.77 + flyingTilt * 0.25
  2994.                     end
  2995.                     previousTilt = flyingTilt
  2996.                     if flyingMomentum.magnitude < 0.1 then
  2997.                         flyingMomentum = Vector3.new(0, 0, 0)
  2998. --                      bodyGyro.cframe = cameraCFrame
  2999.                     else
  3000.                         local momentumOrientation = CFrame.new(Vector3.new(0, 0, 0), flyingMomentum)
  3001.                         local tiltOrientation = CFrame.Angles(0, 0, -20 * flyingTilt)
  3002.                         bodyGyro.cframe = momentumOrientation * tiltOrientation * CFrame.Angles(-0.5 * math.pi * math.min(flyingMomentum.magnitude / PlayerControl.fly_speed, 1), 0, 0)
  3003.                     end
  3004.                     bodyVelocity.velocity = flyingMomentum + Vector3.new(0, 0.15695775618683547, 0)
  3005.                     rootPart.Velocity = flyingMomentum
  3006.                     previousMomentum = flyingMomentum
  3007.                 else
  3008.                     rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  3009.                     PlayerControl.rollingAngle = 0
  3010.                     PlayerControl.rollingOffset = 0
  3011.                     bodyGyro.D = 3250
  3012.                     bodyGyro.P = 400000
  3013.                     bodyVelocity.P = 5000
  3014.                     local cameraDirection = cameraCFrame.lookVector
  3015.                     local walkDirection = Vector3.new(0, 0, 0)
  3016.                     local walkSpeed = 16
  3017.                     if UserInterface:IsKeyDown(Enum.KeyCode.W) then
  3018.                         if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3019.                             walkDirection = Vector3.new(cameraDirection.X + cameraDirection.Z, 0, cameraDirection.Z - cameraDirection.X).unit
  3020.                         elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3021.                             walkDirection = Vector3.new(cameraDirection.X - cameraDirection.Z, 0, cameraDirection.Z + cameraDirection.X).unit
  3022.                         else
  3023.                             walkDirection = Vector3.new(cameraDirection.X, 0, cameraDirection.Z).unit
  3024.                         end
  3025.                     elseif UserInterface:IsKeyDown(Enum.KeyCode.S) then
  3026.                         if UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3027.                             walkDirection = Vector3.new(-cameraDirection.X + cameraDirection.Z, 0, -cameraDirection.Z - cameraDirection.X).unit
  3028.                         elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3029.                             walkDirection = Vector3.new(-cameraDirection.X - cameraDirection.Z, 0, -cameraDirection.Z + cameraDirection.X).unit
  3030.                         else
  3031.                             walkDirection = Vector3.new(-cameraDirection.X, 0, -cameraDirection.Z).unit
  3032.                         end
  3033.                     elseif UserInterface:IsKeyDown(Enum.KeyCode.A) then
  3034.                         walkDirection = Vector3.new(cameraDirection.Z, 0, -cameraDirection.X).unit
  3035.                     elseif UserInterface:IsKeyDown(Enum.KeyCode.D) then
  3036.                         walkDirection = Vector3.new(-cameraDirection.Z, 0, cameraDirection.X).unit
  3037.                     else
  3038.                         walkSpeed = 0
  3039.                     end
  3040.                     if walkSpeed ~= previousWalkSpeed then
  3041.                         if walkSpeed > 0 then
  3042.                             soundRunning:Play()
  3043.                         else
  3044.                             soundRunning:Pause()
  3045.                         end
  3046.                     end
  3047.                     if walkSpeed > 0 then
  3048.                         if pose ~= "Jumping" then
  3049.                             if IsStanding() then
  3050.                                 pose = "Running"
  3051.                             else
  3052.                                 pose = "FreeFall"
  3053.                             end
  3054.                         end
  3055.                         bodyGyro.cframe = CFrame.new(Vector3.new(), walkDirection)
  3056.                         bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000)
  3057.                         bodyVelocity.maxForce = Vector3.new(1000000, bodyVelocity.maxForce.Y, 1000000)
  3058.                     else
  3059.                         if pose ~= "Jumping" then
  3060.                             if IsStanding() then
  3061.                                 pose = "Standing"
  3062.                             else
  3063.                                 pose = "FreeFall"
  3064.                             end
  3065.                         end
  3066.                         -- TODO: find and fix bug that causes torso to rotate back to some angle
  3067.                         bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000) -- Vector3.new(1000000000, 0, 1000000000)
  3068.                         if PlayerControl.pushable then
  3069.                             bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  3070.                         else
  3071.                             bodyVelocity.maxForce = Vector3.new(1000000, 0, 1000000)
  3072.                         end
  3073.                     end
  3074.                     if featherfallEnabled then
  3075.                         local velocity = rootPart.Velocity
  3076.                         if velocity.Y > 50 then
  3077.                             rootPart.Velocity = Vector3.new(velocity.X, 50, velocity.Z)
  3078.                         elseif velocity.Y < -50 then
  3079.                             rootPart.Velocity = Vector3.new(velocity.X, -50, velocity.Z)
  3080.                         end
  3081.                         local distanceVector = rootPartCFrame.p - previousRootPartCFrame.p
  3082.                         local offsetX, offsetY, offsetZ = distanceVector.X, distanceVector.Y, distanceVector.Z
  3083.                         local MAX_MOVEMENT = 50 * 0.03333333507180214
  3084.                         if offsetX > MAX_MOVEMENT then
  3085.                             offsetX = MAX_MOVEMENT
  3086.                         elseif offsetX < -MAX_MOVEMENT then
  3087.                             offsetX = -MAX_MOVEMENT
  3088.                         end
  3089.                         if offsetY > MAX_MOVEMENT then
  3090.                             offsetY = MAX_MOVEMENT
  3091.                         elseif offsetY < -MAX_MOVEMENT then
  3092.                             offsetY = -MAX_MOVEMENT
  3093.                         end
  3094.                         if offsetZ > MAX_MOVEMENT then
  3095.                             offsetZ = MAX_MOVEMENT
  3096.                         elseif offsetZ < -MAX_MOVEMENT then
  3097.                             offsetZ = -MAX_MOVEMENT
  3098.                         end
  3099.                         local offset = Vector3.new(offsetX, offsetY, offsetZ)
  3100.                         if offset ~= distanceVector then
  3101.                             rootPartCFrame = previousRootPartCFrame + offset
  3102.                             --rootPart.CFrame = rootPartCFrame
  3103.                         end
  3104.                     end
  3105.                     local walkingVelocity = walkDirection * walkSpeed
  3106.                     bodyVelocity.velocity = walkingVelocity
  3107.                     if not jumpDebounce and math.abs(rootPart.Velocity.Y) <= 0.1 then
  3108.                         rootPart.Velocity = Vector3.new(walkingVelocity.X, rootPart.Velocity.Y, walkingVelocity.Z)
  3109.                     end
  3110.                     previousWalkSpeed = walkSpeed
  3111.                     if pose == "Jumping" or jumpDebounce then
  3112.                         rightShoulder.MaxVelocity = 0.5
  3113.                         leftShoulder.MaxVelocity = 0.5
  3114.                         rightShoulder.DesiredAngle = 3.14
  3115.                         leftShoulder.DesiredAngle = -3.14
  3116.                         rightHip.DesiredAngle = 0
  3117.                         leftHip.DesiredAngle = 0
  3118.                     elseif pose == "FreeFall" then
  3119.                         rightShoulder.MaxVelocity = 0.5
  3120.                         leftShoulder.MaxVelocity = 0.5
  3121.                         rightShoulder.DesiredAngle = 3.14
  3122.                         leftShoulder.DesiredAngle = -3.14
  3123.                         rightHip.DesiredAngle = 0
  3124.                         leftHip.DesiredAngle = 0
  3125.                     elseif pose == "Seated" then
  3126.                         rightShoulder.MaxVelocity = 0.15
  3127.                         leftShoulder.MaxVelocity = 0.15
  3128.                         rightShoulder.DesiredAngle = 3.14 / 2
  3129.                         leftShoulder.DesiredAngle = -3.14 / 2
  3130.                         rightHip.DesiredAngle = 3.14 / 2
  3131.                         leftHip.DesiredAngle = -3.14 / 2
  3132.                     else
  3133.                         local climbFudge = 0
  3134.                         local amplitude
  3135.                         local frequency
  3136.                         if pose == "Running" then
  3137.                             rightShoulder.MaxVelocity = 0.15
  3138.                             leftShoulder.MaxVelocity = 0.15
  3139.                             amplitude = 1
  3140.                             frequency = 9
  3141.                         elseif (pose == "Climbing") then
  3142.                             rightShoulder.MaxVelocity = 0.5
  3143.                             leftShoulder.MaxVelocity = 0.5
  3144.                             amplitude = 1
  3145.                             frequency = 9
  3146.                             climbFudge = 3.14
  3147.                         else
  3148.                             amplitude = 0.1
  3149.                             frequency = 1
  3150.                         end
  3151.                         local desiredAngle = amplitude * math.sin(totalTime * frequency)
  3152.                         rightShoulder.DesiredAngle = desiredAngle + climbFudge
  3153.                         leftShoulder.DesiredAngle = desiredAngle - climbFudge
  3154.                         rightHip.DesiredAngle = -desiredAngle
  3155.                         leftHip.DesiredAngle = -desiredAngle
  3156.                     end
  3157.                 end
  3158.                 previousRootPartCFrame = rootPartCFrame
  3159.                 RunService.RenderStepped:wait()
  3160.             end
  3161.             if model.Parent ~= nil then
  3162.                 model.Parent = nil
  3163.             end
  3164.             PlayerControl.CreateCharacter()
  3165.         end)
  3166.         humanoid.Health = 100
  3167.         character = model
  3168.         chatAdornee = head
  3169.     elseif characterMode == "pyramid" then
  3170.         if PlayerControl.characterEnabled then
  3171.             PyramidCharacter.visible = true
  3172.             spawn(function()
  3173.                 while PlayerControl.characterEnabled == true do
  3174.                     wait(0.01)
  3175.             Camera.CameraType = "Fixed"
  3176.             PyramidCharacter.camera_distance = (Camera.CFrame.p - Camera.CoordinateFrame.p).magnitude
  3177.             PyramidCharacter.camera_position = Camera.CFrame.p
  3178.             PyramidCharacter.Teleport(Camera.CFrame.p)
  3179.             Player.Character = nil
  3180.                 end
  3181.                 end)
  3182.         else
  3183.             PyramidCharacter.visible = false
  3184.         end
  3185.     end
  3186. end
  3187. function PlayerControl.GetCharacter()
  3188.     return character
  3189. end
  3190. function PlayerControl.GetHead()
  3191.     local characterMode = PlayerControl.characterMode
  3192.     if characterMode == "normal" then
  3193.         return head
  3194.     elseif characterMode == "pyramid" then
  3195.         return PyramidCharacter.core
  3196.     end
  3197. end
  3198. function PlayerControl.GetHumanoid()
  3199.     return humanoid
  3200. end
  3201. function PlayerControl.GetRootPart()
  3202.     return rootPart
  3203. end
  3204. function PlayerControl.GetTorso()
  3205.     return torso
  3206. end
  3207. function PlayerControl.IsEnabled()
  3208.     return PlayerControl.characterEnabled
  3209. end
  3210. function PlayerControl.IsFeatherfallEnabled()
  3211.     return PlayerControl.featherfallEnabled
  3212. end
  3213. function PlayerControl.IsPushable()
  3214.     return PlayerControl.pushable
  3215. end
  3216. function PlayerControl.IsRolling()
  3217.     return PlayerControl.rolling
  3218. end
  3219. function PlayerControl.ResetCharacter()
  3220.     if character and character.Parent then
  3221.         character.Parent = nil
  3222.     end
  3223.     PyramidCharacter.visible = false
  3224. end
  3225. function PlayerControl.SetEnabled(state, no_animation)
  3226.     state = not not state
  3227.     if state ~= PlayerControl.characterEnabled then
  3228.         PlayerControl.characterEnabled = state
  3229.         local characterMode = PlayerControl.characterMode
  3230.         if characterMode == "normal" then
  3231.             local torso = PlayerControl.GetRootPart()
  3232.             local rootPart = PlayerControl.GetRootPart()
  3233.             if rootPart then
  3234.                 if PlayerControl.characterEnabled then
  3235.                     local torso_cframe = Camera.CFrame:toWorldSpace(PlayerControl.hide_torso_object_cframe)
  3236.                     PlayerControl.torso_cframe = torso_cframe
  3237.                     torso.CFrame = torso_cframe
  3238.                     rootPart.CFrame = torso_cframe
  3239.                 else
  3240.                     PlayerControl.hide_torso_object_cframe = Camera.CFrame:toObjectSpace(rootPart.CFrame)
  3241.                 end
  3242.             else
  3243.                 PlayerControl.torso_cframe = Camera.CFrame
  3244.             end
  3245.             if PlayerControl.characterEnabled then
  3246.                 PlayerControl.CreateCharacter()
  3247.                 RunService.Stepped:wait()
  3248.                 coroutine.yield()
  3249.                 if not no_animation then
  3250.                     GraphicalEffects.CrystalRing({base_part = PlayerControl.GetTorso(), crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3251.                 end    
  3252.             else
  3253.                 Player.Character = nil
  3254.                 Camera.CameraType = "Fixed"
  3255.                 if not no_animation then
  3256.                     GraphicalEffects.CrystalRing({position = PlayerControl.GetTorso().Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3257.                 end
  3258.             end
  3259.         else
  3260.             if state then
  3261.                 PlayerControl.CreateCharacter()
  3262.                 RunService.Stepped:wait()
  3263.                 coroutine.yield()
  3264.                 if not no_animation then
  3265.                     GraphicalEffects.CrystalRing({base_part = PyramidCharacter.core, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3266.                 end
  3267.             else
  3268.                 PyramidCharacter.visible = false
  3269.                 if not no_animation then
  3270.                     GraphicalEffects.CrystalRing({position = PyramidCharacter.core.Position, crystal_color = BrickColor.new("Institutional white"), float_duration = 2})
  3271.                 end
  3272.             end
  3273.         end
  3274.     end
  3275. end
  3276. function PlayerControl.SetFeatherfallEnabled(state)
  3277.     state = not not state
  3278.     if state ~= PlayerControl.featherfallEnabled then
  3279.         PlayerControl.featherfallEnabled = state
  3280.         if state then
  3281.         else
  3282.         end
  3283.     end
  3284. end
  3285. function PlayerControl.SetPushable(state)
  3286.     state = not not state
  3287.     if state ~= PlayerControl.pushable then
  3288.         PlayerControl.pushable = state
  3289.         if state then
  3290.         else
  3291.         end
  3292.     end
  3293. end
  3294. function PlayerControl.SetRolling(state)
  3295.     state = not not state
  3296.     if state ~= PlayerControl.rolling then
  3297.         PlayerControl.rolling = state
  3298.         if state then
  3299.         else
  3300.         end
  3301.     end
  3302. end
  3303. function PlayerControl.StartFlying()
  3304.     PlayerControl.fly_speed = PlayerControl.fly_basespeed
  3305.     if torso then
  3306.         flyingMomentum = torso.Velocity + torso.CFrame.lookVector * 3 + Vector3.new(0, 10, 0)
  3307.     else
  3308.         flyingMomentum = Vector3.new()
  3309.     end
  3310.     flyingTilt = 0
  3311.     flying = true
  3312. end
  3313. function PlayerControl.StopFlying()
  3314.     if bodyGyro.cframe then
  3315.         local lookVector = bodyGyro.cframe.lookVector
  3316.         if lookVector.X ~= 0 or lookVector.Z ~= 0 then
  3317.             bodyGyro.cframe = CFrame.new(Vector3.new(), Vector3.new(lookVector.X, 0, lookVector.Z))
  3318.         end
  3319.     end
  3320.     flying = false
  3321. end
  3322.  
  3323. local ControllerCommands = {
  3324.     BALEFIRE_SPEED = 40,
  3325.     };
  3326. function ControllerCommands.BalefireAtMouse()
  3327.     local head = chatAdornee
  3328.     if head then
  3329.         local target = Mouse.Hit.p
  3330.         local origin = head.Position
  3331.         local direction = (target - origin).unit
  3332.         local explosionCount = 0
  3333.         local animation_frame = 0
  3334.         local magic_circle_position = origin + direction * 4
  3335.         local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  3336.         local magic_circle_part = Instance.new("Part")
  3337.         local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  3338.         local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  3339.         local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  3340.         local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  3341.         magic_circle_part.Anchored = true
  3342.         magic_circle_part.Archivable = false
  3343.         magic_circle_part.BottomSurface = "Smooth"
  3344.         magic_circle_part.CanCollide = false
  3345.         magic_circle_part.CFrame = magic_circle_cframe
  3346.         magic_circle_part.FormFactor = "Custom"
  3347.         magic_circle_part.Locked = true
  3348.         magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  3349.         magic_circle_part.TopSurface = "Smooth"
  3350.         magic_circle_part.Transparency = 1
  3351.         magic_circle_mesh.Scale = Vector3.new(60, 60, 0)
  3352.         magic_circle_light.Color = Color3.new(1, 0.5, 1)
  3353.         magic_circle_light.Range = 16
  3354.         magic_circle_light.Shadows = true
  3355.         magic_circle_decal_back.Face = "Back"
  3356.         magic_circle_decal_back.Texture = "rbxassetid://122610943"
  3357.         magic_circle_decal_front.Face = "Front"
  3358.         magic_circle_decal_front.Texture = "rbxassetid://122610943"
  3359.         local function NextExplosion()
  3360.             explosionCount = explosionCount + 1
  3361.             Instance.new("Explosion", workspace).Position = origin + direction * (explosionCount * 8 + 4)
  3362.         end
  3363.         local function AnimateMagicCircle()
  3364.             animation_frame = animation_frame + 1
  3365.             local transparency = (animation_frame / 40) ^ 3
  3366.             if animation_frame == 40 then
  3367.                 pcall(game.Destroy, magic_circle_part)
  3368.             else
  3369.                 if magic_circle_part.Parent ~= workspace then
  3370.                     pcall(Utility.SetProperty, magic_circle_part, "Parent", workspace)
  3371.                 end
  3372.                 head = PlayerControl.GetHead()
  3373.                 if head then
  3374.                     magic_circle_position = head.Position + direction * 4
  3375.                 end
  3376.                 magic_circle_part.CFrame = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * animation_frame / 40 * 1.5)
  3377.                 magic_circle_light.Brightness = 1 - transparency
  3378.                 magic_circle_decal_back.Transparency = transparency
  3379.                 magic_circle_decal_front.Transparency = transparency
  3380.             end
  3381.         end
  3382.         magic_circle_part.Parent = workspace
  3383.         for i = 1, 40 do
  3384.             delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  3385.             delay((i - 1) / 30, AnimateMagicCircle)
  3386.         end
  3387.         for i = 1, 20 do
  3388.             delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  3389.         end
  3390.     end
  3391. end
  3392. function ControllerCommands.ControlRandomDummy()
  3393.     local dummies = {}
  3394.     local numDummies = 0
  3395.     for _, character in ipairs(workspace:GetChildren()) do
  3396.         local name = tostring(character)
  3397.         if name == "???" or name == "Dummy" then
  3398.             local head, humanoid
  3399.             for _, child in ipairs(character:GetChildren()) do
  3400.                 local className = child.ClassName
  3401.                 if className == "Part" and tostring(child) == "Head" then
  3402.                     head = child
  3403.                     if humanoid then
  3404.                         break
  3405.                     end
  3406.                 elseif className == "Humanoid" then
  3407.                     if child.Health > 0 then
  3408.                         humanoid = child
  3409.                         if head then
  3410.                             break
  3411.                         end
  3412.                     else
  3413.                         break
  3414.                     end
  3415.                 end
  3416.             end
  3417.             if head and humanoid then
  3418.                 numDummies = numDummies + 1
  3419.                 dummies[numDummies] = {character, head, humanoid}
  3420.             end
  3421.         end
  3422.     end
  3423.     if numDummies > 0 then
  3424.         local dummy = dummies[math.random(numDummies)]
  3425.         Player.Character = dummy[1]
  3426.         chatAdornee = dummy[2]
  3427.         Camera.CameraSubject = dummy[3]
  3428.         Camera.CameraType = "Track"
  3429.     end
  3430. end
  3431. function ControllerCommands.Decalify(textures, exclusion)
  3432.     local objects = workspace:GetChildren()
  3433.     for _, object in ipairs(objects) do
  3434.         if not exclusion[object] then
  3435.             for _, child in ipairs(object:GetChildren()) do
  3436.                 objects[#objects + 1] = child
  3437.             end
  3438.             if object:IsA("BasePart") then
  3439.                 local texture = textures[math.random(#textures)]
  3440.                 local face_left = Instance.new("Decal", object)
  3441.                 face_left.Face = Enum.NormalId.Left
  3442.                 face_left.Texture = texture
  3443.                 local face_right = Instance.new("Decal", object)
  3444.                 face_right.Face = Enum.NormalId.Right
  3445.                 face_right.Texture = texture
  3446.                 local face_bottom = Instance.new("Decal", object)
  3447.                 face_bottom.Face = Enum.NormalId.Bottom
  3448.                 face_bottom.Texture = texture
  3449.                 local face_top = Instance.new("Decal", object)
  3450.                 face_top.Face = Enum.NormalId.Top
  3451.                 face_top.Texture = texture
  3452.                 local face_front = Instance.new("Decal", object)
  3453.                 face_front.Face = Enum.NormalId.Front
  3454.                 face_front.Texture = texture
  3455.                 local face_back = Instance.new("Decal", object)
  3456.                 face_back.Face = Enum.NormalId.Back
  3457.                 face_back.Texture = texture
  3458.             end
  3459.         end
  3460.     end
  3461. end
  3462.  
  3463. function ControllerCommands.ShootMissileAroundMouse(amount, offset, delayTime)
  3464.     local exclusionList = {}
  3465.     local playerHead = PlayerControl.GetHead()
  3466.     local playerTorso = PlayerControl.GetTorso()
  3467.     if playerHead and playerTorso then
  3468.         exclusionList[playerTorso] = true
  3469.         local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  3470.         local targetPart, pointOnPart
  3471.         if humanoid and torso then
  3472.             targetPart, pointOnPart = torso, Vector3.new()
  3473.         else
  3474.             local target = Mouse.Target
  3475.             if target then
  3476.                 targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  3477.             else
  3478.                 return
  3479.             end
  3480.         end
  3481.         if targetPart then
  3482.             delayTime = delayTime or 0
  3483.             local index = 1
  3484.             local targetPoint = targetPart.CFrame * pointOnPart
  3485.             local rotation_offset_angles = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, 0).unit
  3486.             local rotation_offset = CFrame.Angles(rotation_offset_angles.x, rotation_offset_angles.y, 0)
  3487.             local angle_x = 0
  3488.             local angle_x_step = math.tau / math.phi
  3489.             for i = 1, 8 * amount do
  3490.                 angle_x = angle_x + angle_x_step
  3491.                 local direction = rotation_offset * (CFrame.Angles(0, math.tau * index / amount, 0) * CFrame.Angles(angle_x, 0, 0).lookVector)
  3492.                 local blocked = workspace:FindPartOnRay(Ray.new(targetPoint, direction * offset), targetPart.Parent)
  3493.                 if not blocked then
  3494.                     local p0 = targetPart
  3495.                     local p1 = pointOnPart
  3496.                     local p2 = direction
  3497.                     local p3 = offset
  3498.                     GraphicalEffects.ShootMissile(p0, p1, p2, function() return p0 end, p3, true)
  3499.                     index = index + 1
  3500.                     if index > amount then
  3501.                         break
  3502.                     end
  3503.                 end
  3504.             end
  3505.         end
  3506.     end
  3507. end
  3508.  
  3509. function ControllerCommands.BigLaser(target)
  3510.     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})
  3511. end
  3512. function ControllerCommands.BigLaserAtMouse()
  3513.     ControllerCommands.BigLaser(Mouse.Hit.p)
  3514. end
  3515. function ControllerCommands.ShootMissile(targetPart, pointOnPart, direction)
  3516.     GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction)
  3517. end
  3518. function ControllerCommands.ShootMissileAtMouse(amount, spread, delayTime)
  3519.     local exclusionList = {}
  3520.     local playerHead = PlayerControl.GetHead()
  3521.     local playerTorso = PlayerControl.GetTorso()
  3522.     if playerHead and playerTorso then
  3523.         exclusionList[playerTorso] = true
  3524.         local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  3525.         local targetPart, pointOnPart
  3526.         if humanoid and torso then
  3527.             targetPart, pointOnPart = torso, Vector3.new()
  3528.         else
  3529.             local target = Mouse.Target
  3530.             if target then
  3531.                 targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  3532.             else
  3533.                 return
  3534.             end
  3535.         end
  3536.         if targetPart then
  3537.             local direction = (Mouse.Hit.p - playerHead.Position).unit
  3538.             delayTime = delayTime or 0
  3539.             for index = 1, amount do
  3540.                 local angles = math.tau * (index - 0.5) * spread / amount * Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit
  3541.                 TaskScheduler.Schedule(delayTime * (index - 1), ControllerCommands.ShootMissile, targetPart, pointOnPart, CFrame.Angles(angles.X, angles.Y, angles.Z) * direction)
  3542.             end
  3543.         end
  3544.     end
  3545. end
  3546.  
  3547. local _ = string.char
  3548. function ControllerCommands.HugeExplosionOfDoom(position)
  3549.     local connections = {}
  3550.     local parts = {}
  3551.     local cframe = CFrame.new(position)
  3552.     local function ExplosionHit(part)
  3553.         if part:GetMass() < 10000 and part.Parent ~= Camera then
  3554.             parts[part] = true
  3555.             part.Anchored = true
  3556.             part:BreakJoints()
  3557.             part.BrickColor = BrickColor.new("Instituational white")
  3558.         end
  3559.     end
  3560.     for i = 1, 4 do
  3561.         local quantity = 0.5 * i * (1 + i)
  3562.         local fraction = math.tau / quantity
  3563.         for x = 1, quantity do
  3564.             for y = 1, quantity do
  3565.                 local explosion = Instance.new("Explosion")
  3566.                 connections[#connections + 1] = explosion.Hit:connect(ExplosionHit)
  3567.                 explosion.BlastRadius = 5
  3568.                 explosion.Position = cframe * (CFrame.Angles(fraction * x, fraction * y, 0) * Vector3.new((i - 1) * 6, 0, 0))
  3569.                 explosion.Parent = workspace
  3570.             end
  3571.         end
  3572.         wait(0.075)
  3573.     end
  3574.     for part in pairs(parts) do
  3575.         for _, child in ipairs(part:GetChildren()) do
  3576.             if child:IsA("BodyMover") then
  3577.                 child:Destroy()
  3578.             end
  3579.         end
  3580.         local mass = part:GetMass()
  3581.         local velocity = CFrame.Angles(math.tau * math.random(), math.tau * math.random(), 0) * Vector3.new(25, 0, 0)
  3582.         local bodythrust = Instance.new("BodyThrust")
  3583.         bodythrust.force = mass * -velocity
  3584.         bodythrust.Parent = part
  3585.         local bodyforce = Instance.new("BodyForce")
  3586.         bodyforce.force = mass * Vector3.new(0, 196.2, 0)
  3587.         bodyforce.Parent = part
  3588.         part.Anchored = false
  3589.         part.Reflectance = 1
  3590.         part.RotVelocity = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5)
  3591.         part.Transparency = 0.5
  3592.         part.Velocity = (part.CFrame - part.Position) * velocity
  3593.     end
  3594.     for _, connection in ipairs(connections) do
  3595.         connection:disconnect()
  3596.     end
  3597.     for i = 0, 99 do
  3598.         delay(i / 10, function()
  3599.             for part in pairs(parts) do
  3600.                 local new_transparency = 0.5 * (1 + i / 50)
  3601.                 part.Reflectance = 0.98 * part.Reflectance
  3602.                 if new_transparency > part.Transparency then
  3603.                     part.Transparency = new_transparency
  3604.                 end
  3605.             end
  3606.         end)
  3607.     end
  3608.     delay(10, function()
  3609.         for part in pairs(parts) do
  3610.             pcall(part.Destroy, part)
  3611.         end
  3612.     end)
  3613. end
  3614. function ControllerCommands.HugeExplosionOfDoomAtMouse()
  3615.     ControllerCommands.HugeExplosionOfDoom(Mouse.Hit.p)
  3616. end
  3617.  
  3618. function ControllerCommands.SpaceHyperBeam(asd)
  3619.     GraphicalEffects.SpaceHyperBeam(asd)
  3620. end
  3621. function ControllerCommands.SpaceHyperBeamAtMouse()
  3622.     ControllerCommands.SpaceHyperBeam(Mouse.Hit.p)
  3623. end
  3624. function ControllerCommands.ConcentratedSpaceHyperBeamAtMouse()
  3625.     local p = Mouse.Hit.p; for i = 1, 50 do GraphicalEffects.SpaceHyperBeam(p) end
  3626. end
  3627.  
  3628. ControllerCommands.MAX_SPACE_HYPER_BEAM_LENGTH = 20
  3629. ControllerCommands.SPACE_HYPER_BEAM_DELAY = 0.1
  3630. ControllerCommands.SPACE_HYPER_BEAM_SPACING = 20
  3631. ControllerCommands.SPACE_HYPER_BEAM_START_OFFSET = 20
  3632.  
  3633. function ControllerCommands.SpawnSapientRock(position)
  3634.     GraphicalEffects.SpawnSapientRock(position)
  3635. end
  3636. function ControllerCommands.SpawnSapientRockAtMouse()
  3637.     ControllerCommands.SpawnSapientRock(Mouse.Hit.p)
  3638. end
  3639. function ControllerCommands.TeleportCharacterToMouse()
  3640.     if PlayerControl.IsEnabled() then
  3641.         local torso = PlayerControl.GetTorso()
  3642.         if torso then
  3643.             local pos = Mouse.Hit.p + Vector3.new(0, 5, 0)
  3644.             torso.CFrame = CFrame.new(pos, pos + torso.CFrame.lookVector)
  3645.         end
  3646.     else
  3647.         local new_focus_position = Mouse.Hit.p
  3648.         local direction_vector = Camera.CoordinateFrame.lookVector
  3649.         local new_focus = CFrame.new(new_focus_position, new_focus_position + direction_vector)
  3650.         Camera.CoordinateFrame = new_focus * CFrame.new(0, 0, 25)
  3651.         Camera.CFrame = new_focus
  3652.     end
  3653. end
  3654. function ControllerCommands.FixLimbs(target)
  3655.     local targetCaseInsensitive = Utility.CaseInsensitivePattern(target)
  3656.     local character = PlayerControl.GetCharacter()
  3657.     local user_torso = PlayerControl.GetTorso()
  3658.     local objects = workspace:GetChildren()
  3659.     for _, object in ipairs(objects) do
  3660.         local humanoid
  3661.         for _, child in ipairs(object:GetChildren()) do
  3662.             objects[#objects + 1] = child
  3663.             if child:IsA("Humanoid") then
  3664.                 humanoid = child
  3665.             end
  3666.         end
  3667.         if humanoid and object.Name:lower():match(targetCaseInsensitive) then
  3668.             local bc
  3669.             for _, o in ipairs(object:GetChildren()) do
  3670.                 if o:IsA("BodyColors") then
  3671.                     bc = o
  3672.                 end
  3673.             end
  3674.             local fixing = false
  3675.             local torso = object:FindFirstChild("Torso")
  3676.             if torso and torso:IsA("Part") then
  3677.                 if not object:FindFirstChild("Left Arm") or not torso:FindFirstChild("Left Shoulder") then
  3678.                     fixing = true
  3679.                     local s = character["Left Arm"]:Clone()
  3680.                     local j = user_torso["Left Shoulder"]:Clone()
  3681.                     j.Part0 = torso
  3682.                     j.Part1 = s
  3683.                     j.CurrentAngle = 0
  3684.                     j.DesiredAngle = 0
  3685.                     j.MaxVelocity = 0
  3686.                     s.Anchored = true
  3687.                     s.BrickColor = bc and bc.LeftArmColor or BrickColor.Yellow()
  3688.                     local p1, r1 = s.Position, s.CFrame.lookVector
  3689.                     s.Parent = object
  3690.                     TaskScheduler.Start(function()
  3691.                         for i = 1, 30 do
  3692.                             RunService.Stepped:wait()
  3693.                             local a = i / 30
  3694.                             local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  3695.                             local p = p1:Lerp(c2.p, a)
  3696.                             s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  3697.                         end
  3698.                         s.Anchored = false
  3699.                         j.Parent = torso
  3700.                     end)
  3701.                 end
  3702.                 if not object:FindFirstChild("Right Arm") or not torso:FindFirstChild("Right Shoulder") then
  3703.                     fixing = true
  3704.                     local s = character["Right Arm"]:Clone()
  3705.                     local j = user_torso["Right Shoulder"]:Clone()
  3706.                     j.Part0 = torso
  3707.                     j.Part1 = s
  3708.                     j.CurrentAngle = 0
  3709.                     j.DesiredAngle = 0
  3710.                     j.MaxVelocity = 0
  3711.                     s.Anchored = true
  3712.                     s.BrickColor = bc and bc.RightArmColor or BrickColor.Yellow()
  3713.                     local p1, r1 = s.Position, s.CFrame.lookVector
  3714.                     s.Parent = object
  3715.                     TaskScheduler.Start(function()
  3716.                         for i = 1, 30 do
  3717.                             RunService.Stepped:wait()
  3718.                             local a = i / 30
  3719.                             local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  3720.                             local p = p1:Lerp(c2.p, a)
  3721.                             s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  3722.                         end
  3723.                         s.Anchored = false
  3724.                         j.Parent = torso
  3725.                     end)
  3726.                 end
  3727.                 if not object:FindFirstChild("Left Leg") or not torso:FindFirstChild("Left Hip") then
  3728.                     fixing = true
  3729.                     local s = character["Left Leg"]:Clone()
  3730.                     local j = user_torso["Left Hip"]:Clone()
  3731.                     j.Part0 = torso
  3732.                     j.Part1 = s
  3733.                     j.CurrentAngle = 0
  3734.                     j.DesiredAngle = 0
  3735.                     j.MaxVelocity = 0
  3736.                     s.Anchored = true
  3737.                     s.BrickColor = bc and bc.LeftLegColor or BrickColor.new("Br. yellowish green")
  3738.                     local p1, r1 = s.Position, s.CFrame.lookVector
  3739.                     s.Parent = object
  3740.                     TaskScheduler.Start(function()
  3741.                         for i = 1, 30 do
  3742.                             RunService.Stepped:wait()
  3743.                             local a = i / 30
  3744.                             local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  3745.                             local p = p1:Lerp(c2.p, a)
  3746.                             s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  3747.                         end
  3748.                         s.Anchored = false
  3749.                         j.Parent = torso
  3750.                     end)
  3751.                 end
  3752.                 if not object:FindFirstChild("Right Leg") or not torso:FindFirstChild("Right Hip") then
  3753.                     fixing = true
  3754.                     local s = character["Right Leg"]:Clone()
  3755.                     local j = user_torso["Right Hip"]:Clone()
  3756.                     j.Part0 = torso
  3757.                     j.Part1 = s
  3758.                     j.CurrentAngle = 0
  3759.                     j.DesiredAngle = 0
  3760.                     j.MaxVelocity = 0
  3761.                     s.Anchored = true
  3762.                     s.BrickColor = bc and bc.RightLegColor or BrickColor.new("Br. yellowish green")
  3763.                     local p1, r1 = s.Position, s.CFrame.lookVector
  3764.                     s.Parent = object
  3765.                     TaskScheduler.Start(function()
  3766.                         for i = 1, 30 do
  3767.                             RunService.Stepped:wait()
  3768.                             local a = i / 30
  3769.                             local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  3770.                             local p = p1:Lerp(c2.p, a)
  3771.                             s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  3772.                         end
  3773.                         s.Anchored = false
  3774.                         j.Parent = torso
  3775.                     end)
  3776.                 end
  3777.                 if fixing then
  3778.                     TaskScheduler.Schedule(1, function()
  3779.                         local anim = object:FindFirstChild("Animate")
  3780.                         if anim and anim.ClassName == "LocalScript" then
  3781.                             anim.Disabled = true
  3782.                             wait(0.5)
  3783.                             anim.Disabled = false
  3784.                         end
  3785.                     end)
  3786.                 end
  3787.             end
  3788.         end
  3789.     end
  3790. end
  3791.  
  3792. function ControllerCommands.ActivateTelekinesis(part)
  3793.     if part then
  3794.         local removedItems = {}
  3795.         for _, child in ipairs(part:GetChildren()) do
  3796.             if child:IsA("BodyMover") then
  3797.                 removedItems[#removedItems + 1] = child
  3798.                 child.Parent = nil
  3799.             end
  3800.         end
  3801.         local damage_debounce = {}
  3802.         local mass = part:GetMass()
  3803.         local gripDistance = (Mouse.Origin.p - Mouse.Hit.p).magnitude
  3804.         local connection = part.Touched:connect(function(hit)
  3805.             local character = PlayerControl.GetCharacter()
  3806.             if not hit.Anchored and hit.CanCollide and not (character and hit:IsDescendantOf(character)) then
  3807.                 local hit_model = hit
  3808.                 local hit_humanoid
  3809.                 while hit_model and hit_model.Parent ~= workspace do
  3810.                     hit_model = hit_model.Parent
  3811.                 end
  3812.                 if hit_model and hit_model:IsA("Model") then
  3813.                     for _, child in ipairs(hit_model:GetChildren()) do
  3814.                         if child:IsA("Humanoid") then
  3815.                             hit_humanoid = child
  3816.                             break
  3817.                         end
  3818.                     end
  3819.                 end
  3820.                 local speed_diff = (part.Velocity - hit.Velocity).magnitude
  3821.                 if hit_humanoid then
  3822.                     if not damage_debounce[hit_humanoid] and hit.Velocity.magnitude > 100 and speed_diff >= 100 then
  3823.                         local damage = 0.75 * speed_diff
  3824.                         damage_debounce[hit_humanoid] = true
  3825.                         hit_humanoid:TakeDamage(damage)
  3826.                         wait(2)
  3827.                         damage_debounce[hit_humanoid] = nil
  3828.                     end
  3829.                 else
  3830.                     if speed_diff * speed_diff > hit:GetMass() then
  3831.                         hit:BreakJoints()
  3832.                     end
  3833.                 end
  3834.             end
  3835.         end)
  3836.         local bodyPosition = Instance.new("BodyPosition", part)
  3837.         bodyPosition.maxForce = Vector3.new(1e6, 1e6, 1e6) * mass
  3838.         while UserInterface:IsKeyDown(Enum.KeyCode["T"]) do
  3839.             if UserInterface:IsKeyDown(Enum.KeyCode["I"]) then
  3840.                 gripDistance = gripDistance * 1.033 + 2
  3841.             end
  3842.             if UserInterface:IsKeyDown(Enum.KeyCode["K"]) then
  3843.                 gripDistance = gripDistance / 1.033 - 2
  3844.             end
  3845.             bodyPosition.position = Mouse.Origin.p + Mouse.Hit.lookVector * gripDistance
  3846.             RunService.Stepped:wait()
  3847.         end
  3848.         for _, child in ipairs(removedItems) do
  3849.             pcall(Utility.SetProperty, child, "Parent", part)
  3850.         end
  3851.         part:MakeJoints()
  3852.         game:GetService("Debris"):AddItem(bodyPosition, 0)
  3853.         TaskScheduler.Schedule(3, function() connection:disconnect() end)
  3854.     end
  3855. end
  3856.  
  3857. function ControllerCommands.ControlRandomDummy()
  3858.     local dummies = {}
  3859.     local numDummies = 0
  3860.     for _, character in ipairs(workspace:GetChildren()) do
  3861.         local name = tostring(character)
  3862.         if name == "Dummy" then
  3863.             local head, humanoid
  3864.             for _, child in ipairs(character:GetChildren()) do
  3865.                 local className = child.ClassName
  3866.                 if className == "Part" and tostring(child) == "Head" then
  3867.                     head = child
  3868.                     if humanoid then
  3869.                         break
  3870.                     end
  3871.                 elseif className == "Humanoid" then
  3872.                     if child.Health > 0 then
  3873.                         humanoid = child
  3874.                         if head then
  3875.                             break
  3876.                         end
  3877.                     else
  3878.                         break
  3879.                     end
  3880.                 end
  3881.             end
  3882.             if head and humanoid then
  3883.                 numDummies = numDummies + 1
  3884.                 dummies[numDummies] = {character, head, humanoid}
  3885.             end
  3886.         end
  3887.     end
  3888.     if numDummies > 0 then
  3889.         local dummy = dummies[math.random(numDummies)]
  3890.         Player.Character = dummy[1]
  3891.    
  3892.         Camera.CameraSubject = dummy[3]
  3893.         Camera.CameraType = "Track"
  3894.     end
  3895. end
  3896.  
  3897. local GK = {
  3898.     Keys = {};
  3899.     Commands = {};
  3900. };
  3901.  
  3902. NewCommand=function(nme, usg, func)
  3903.     table.insert(GK.Commands, {['Name']=nme, ['Usage']=usg, ['Function']=func})
  3904. end
  3905. NewKey=function(nme, key, func)
  3906.     table.insert(GK.Keys, {['Name']=nme, ['Key']=key, ['Function']=func})
  3907. end
  3908.  
  3909. onChatted=function(msg)
  3910.     if string.sub(msg,1,1) == "/" then
  3911.         for _,cmd in pairs(GK.Commands) do
  3912.             local tosay = "/"..cmd['Usage']
  3913.             if string.sub(msg,1,string.len(tosay)) == tosay then
  3914.                 cmd.Function(string.sub(msg,string.len(tosay)+2))
  3915.             end
  3916.         end
  3917.     else
  3918.         ChatBubble.Create(msg)
  3919.     end
  3920. end
  3921.  
  3922. onButtonClick=function()
  3923.     for _,key in pairs(GK.Keys) do
  3924.         if UserInterface:IsKeyDown(Enum.KeyCode[key.Key]) then
  3925.                 key.Function()
  3926.         end
  3927.     end
  3928. end
  3929.  
  3930. NewCommand("Body Seats", "bs", function(args)
  3931.     local torso = PlayerControl.GetTorso()
  3932.     local offset1 = CFrame.Angles(0.5 * math.pi, 0, 0) * CFrame.new(0, 1.75, 0)
  3933.     local offset2 = CFrame.Angles(0.5 * math.pi, 0, 0.5 * math.pi) * CFrame.new(0, 2.75, 0)
  3934.     local offset3 = CFrame.Angles(0.5 * math.pi, 0, -0.5 * math.pi) * CFrame.new(0, 2.75, 0)
  3935.     local seat1 = Instance.new("Seat")
  3936.     seat1.BrickColor = BrickColor.new("Black")
  3937.     seat1.FormFactor = "Custom"
  3938.     seat1.Locked = true
  3939.     seat1.Size = Vector3.new(2, 0.5, 2)
  3940.     seat1.TopSurface = "Weld"
  3941.     local seat2 = seat1:Clone()
  3942.     local seat3 = seat1:Clone()
  3943.     local joint1 = Instance.new("Weld", seat1)
  3944.     local joint2 = Instance.new("Weld", seat2)
  3945.     local joint3 = Instance.new("Weld", seat3)
  3946.     seat1.CFrame = torso.CFrame * offset1
  3947.     seat2.CFrame = torso.CFrame * offset2
  3948.     seat3.CFrame = torso.CFrame * offset3
  3949.     joint1.Part0 = torso
  3950.     joint1.Part1 = seat1
  3951.     joint1.C0 = offset1
  3952.     joint2.Part0 = torso
  3953.     joint2.Part1 = seat2
  3954.     joint2.C0 = offset2
  3955.     joint3.Part0 = torso
  3956.     joint3.Part1 = seat3
  3957.     joint3.C0 = offset3
  3958.     seat1.Parent = workspace
  3959.     seat2.Parent = workspace
  3960.     seat3.Parent = workspace end)
  3961.  
  3962.  
  3963. NewCommand("PyramidChar", "pyr", function(args)
  3964.  PlayerControl.characterMode = PlayerControl.characterMode == "pyramid" and "normal" or "pyramid"
  3965.  end)
  3966.  
  3967. NewCommand("Chat theme", "ctheme", function(msg)
  3968.      ChatBubble.SetTheme(msg)
  3969.  end)
  3970.  
  3971. NewCommand("Reset control", "resetc", function()
  3972.     if not game.Players:FindFirstChild(Player.Name) then
  3973.         chatAdornee = PlayerControl.GetHead()
  3974.         Camera.CameraSubject = PlayerControl.GetHead()
  3975.          Player.Humanoid = PlayerControl.GetHumanoid()
  3976.      else
  3977.          chatAdornee = game.Players[Player.Name].Character.Head
  3978.     end
  3979. end)
  3980.  
  3981.  
  3982. NewKey("Dummy", "Z", function()
  3983.      Utility.CreateDummy(Mouse.Hit, "Dummy", workspace)
  3984.  end)
  3985.  
  3986. NewKey("Dummys ", "U", function()
  3987.     Utility.SurroundWithDummies(workspace)
  3988.      end)
  3989.  
  3990. NewKey("Control Dummy", "X", function()
  3991.      ControllerCommands.ControlRandomDummy()
  3992.      end)
  3993.  
  3994. NewKey("Flying", "C", function()
  3995.      if flying then PlayerControl.StopFlying()
  3996.     else PlayerControl.StartFlying()
  3997.      end
  3998. end)
  3999.  
  4000. NewKey("Laser", "V", function()
  4001.     GraphicalEffects.ShootLaserOfDeath(Mouse.Hit.p)
  4002. end)
  4003.  
  4004. NewKey("Destroy", "B", function()
  4005.      local targ = Mouse.Target
  4006.     GraphicalEffects.CrystalRing({base_part = targ, crystal_color = BrickColor.new("Really black"), float_duration = 1})
  4007.      targ:remove()
  4008.      targ=nil;
  4009.  end)
  4010.  
  4011. NewKey("SLaser", "N", function()
  4012.      GraphicalEffects.SpaceHyperBeam(Mouse.Hit.p)
  4013.  end)
  4014.  
  4015. NewKey("Balefire", "M", function()
  4016.     ControllerCommands.BalefireAtMouse()
  4017.  end)
  4018.  
  4019. NewKey("Missiles", "F", function()
  4020.     ControllerCommands.ShootMissileAroundMouse(19, 50, 1 / 19)
  4021.     end)
  4022.  
  4023. NewKey("BigLaser", "G", function()
  4024.      ControllerCommands.BigLaserAtMouse()
  4025.      end)
  4026.  
  4027. NewKey("Possess", "H", function()
  4028.     chatAdornee = Mouse.Target
  4029.     end)
  4030.  
  4031. NewKey("Rock", "J", function()
  4032.      ControllerCommands.SpawnSapientRockAtMouse()
  4033.  end)
  4034.  
  4035. NewKey("ActivateTelekinesis", "T", function()
  4036.      ControllerCommands.ActivateTelekinesis(Mouse.Target)
  4037.  end)
  4038.  
  4039. NewKey("TeleportCharacterToMouse", "E", function()
  4040.      ControllerCommands.TeleportCharacterToMouse()
  4041.  end)
  4042.  
  4043. NewKey("ShowHide", "Q", function()
  4044.      for _,p in pairs(game.Workspace:children())
  4045.      do if p.Name == Player.Name then
  4046.         p:remove()
  4047.      end
  4048.      end
  4049.      PlayerControl.SetEnabled(not PlayerControl.IsEnabled())
  4050.     end)
  4051.  
  4052. Mouse.KeyDown:connect(onButtonClick)
  4053. Player.Chatted:connect(onChatted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement