Advertisement
swagergod

omglame

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