Advertisement
Derek1017

Secret

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