Advertisement
waconline

gatekeeper

Feb 12th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 304.94 KB | None | 0 0
  1. --https://github.com/Mokiros/roblox-FE-compatibility
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code V2 by Mokiros")
  7. local RealPlayer = RealPlayer
  8. script.Parent = RealPlayer.Character
  9.  
  10. --Fake event to make stuff like Mouse.KeyDown work
  11. local Disconnect_Function = function(this)
  12. this[1].Functions[this[2]] = nil
  13. end
  14. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  15. local FakeEvent_Metatable = {__index={
  16. Connect = function(this,f)
  17. local i = tostring(math.random(0,10000))
  18. while this.Functions[i] do
  19. i = tostring(math.random(0,10000))
  20. end
  21. this.Functions[i] = f
  22. return setmetatable({this,i},Disconnect_Metatable)
  23. end
  24. }}
  25. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  26. local function fakeEvent()
  27. return setmetatable({Functions={}},FakeEvent_Metatable)
  28. end
  29.  
  30. --Creating fake input objects with fake variables
  31. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  32. FakeMouse.keyUp = FakeMouse.KeyUp
  33. FakeMouse.keyDown = FakeMouse.KeyDown
  34. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  35. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  36. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  37. end}
  38. --Merged 2 functions into one by checking amount of arguments
  39. CAS.UnbindAction = CAS.BindAction
  40.  
  41. --This function will trigger the events that have been :Connect()'ed
  42. local function TriggerEvent(self,ev,...)
  43. for _,f in pairs(self[ev].Functions) do
  44. f(...)
  45. end
  46. end
  47. FakeMouse.TriggerEvent = TriggerEvent
  48. UIS.TriggerEvent = TriggerEvent
  49.  
  50. --Client communication
  51. local Event = Instance.new("RemoteEvent")
  52. Event.Name = "UserInput_Event"
  53. Event.OnServerEvent:Connect(function(plr,io)
  54. if plr~=RealPlayer then return end
  55. FakeMouse.Target = io.Target
  56. FakeMouse.Hit = io.Hit
  57. if not io.isMouse then
  58. local b = io.UserInputState == Enum.UserInputState.Begin
  59. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  60. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  61. end
  62. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  63. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  77. local Mouse = owner:GetMouse()
  78. local UIS = game:GetService("UserInputService")
  79. local input = function(io,RobloxHandled)
  80. if RobloxHandled then return end
  81. --Since InputObject is a client-side instance, we create and pass table instead
  82. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  83. end
  84. UIS.InputBegan:Connect(input)
  85. UIS.InputEnded:Connect(input)
  86.  
  87. local h,t
  88. --Give the server mouse data every second frame, but only if the values changed
  89. --If player is not moving their mouse, client won't fire events
  90. local HB = game:GetService("RunService").Heartbeat
  91. while true do
  92. if h~=Mouse.Hit or t~=Mouse.Target then
  93. h,t=Mouse.Hit,Mouse.Target
  94. Event:FireServer({isMouse=true,Target=t,Hit=h})
  95. end
  96. --Wait 2 frames
  97. for i=1,2 do
  98. HB:Wait()
  99. end
  100. end]==],script)
  101.  
  102. ----Sandboxed game object that allows the usage of client-side methods and services
  103. --Real game object
  104. local RealGame = game
  105.  
  106. --Metatable for fake service
  107. local FakeService_Metatable = {
  108. __index = function(self,k)
  109. local s = rawget(self,"_RealService")
  110. if s then
  111. return typeof(s[k])=="function"
  112. and function(_,...)return s[k](s,...)end or s[k]
  113. end
  114. end,
  115. __newindex = function(self,k,v)
  116. local s = rawget(self,"_RealService")
  117. if s then s[k]=v end
  118. end
  119. }
  120. local function FakeService(t,RealService)
  121. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  122. return setmetatable(t,FakeService_Metatable)
  123. end
  124.  
  125. --Fake game object
  126. local FakeGame = {
  127. GetService = function(self,s)
  128. return rawget(self,s) or RealGame:GetService(s)
  129. end,
  130. Players = FakeService({
  131. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  132. },"Players"),
  133. UserInputService = FakeService(UIS,"UserInputService"),
  134. ContextActionService = FakeService(CAS,"ContextActionService"),
  135. RunService = FakeService({
  136. _btrs = {},
  137. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  138. BindToRenderStep = function(self,name,_,fun)
  139. self._btrs[name] = self.Heartbeat:Connect(fun)
  140. end,
  141. UnbindFromRenderStep = function(self,name)
  142. self._btrs[name]:Disconnect()
  143. end,
  144. },"RunService")
  145. }
  146. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  147. FakeGame.service = FakeGame.GetService
  148. FakeService(FakeGame,game)
  149. --Changing owner to fake player object to support owner:GetMouse()
  150. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  151. end
  152. --Old version of the script was leaked so now it's worthless,
  153. -- so I can't get any money for it anymore. So I'll just share
  154. -- the code of the latest version now.
  155. -- The code is broken as a whole but many of the components
  156. -- are still functional. Maybe you can make your own module
  157. -- loader to fix it. Use the code of the modules as you please.
  158. -- If you can get local loadstring to work, that should fix
  159. -- everything. Good luck.
  160. local session_id = math.floor(tick() * 10)
  161. local local_script_template = script:Clone()
  162. local source_value_name
  163. local_script_template.Disabled = true
  164. for _, child in ipairs(local_script_template:GetChildren()) do
  165. if child:IsA("StringValue") then
  166. if string.lower(child.Name) ~= "owner" then
  167. source_value_name = child.Name
  168. end
  169. child.Value = ""
  170. break
  171. end
  172. end
  173. script:ClearAllChildren()
  174. script.Parent = nil
  175. if not source_value_name then
  176. source_value_name = ...
  177. if source_value_name then
  178. local source_value = Instance.new("StringValue", local_script_template)
  179. source_value.Name = source_value_name
  180. else
  181. if not (NewLocalScript and NewScript) then
  182. print("Script builder is incompatible.")
  183. end
  184. source_value_name = "Source"
  185. local_script_template = nil
  186. end
  187. end
  188. local Module = {}
  189. Module.name = "Module"
  190. Module.source = string.format([[
  191. local _ENV = {
  192. Axes = {
  193. new = Axes.new
  194. },
  195. BrickColor = {
  196. Black = BrickColor.Black,
  197. Blue = BrickColor.Blue,
  198. DarkGray = BrickColor.DarkGray,
  199. Gray = BrickColor.Gray,
  200. Green = BrickColor.Green,
  201. New = BrickColor.New,
  202. Random = BrickColor.Random,
  203. Red = BrickColor.Red,
  204. White = BrickColor.White,
  205. Yellow = BrickColor.Yellow,
  206. new = BrickColor.new,
  207. palette = BrickColor.palette,
  208. random = BrickColor.random
  209. },
  210. CFrame = {
  211. Angles = CFrame.Angles,
  212. fromAxisAngle = CFrame.fromAxisAngle,
  213. fromEulerAnglesXYZ = CFrame.fromEulerAnglesXYZ,
  214. new = CFrame.new
  215. },
  216. CellId = {
  217. new = CellId.new
  218. },
  219. Color3 = {
  220. new = Color3.new
  221. },
  222. Delay = Delay,
  223. Enum = Enum,
  224. Faces = {
  225. new = Faces.new
  226. },
  227. Game = Game,
  228. Instance = {
  229. Lock = Instance.Lock,
  230. Unlock = Instance.Unlock,
  231. new = Instance.new
  232. },
  233. LoadLibrary = LoadLibrary,
  234. LoadRobloxLibrary = LoadRobloxLibrary,
  235. PluginManager = PluginManager,
  236. Ray = {
  237. new = Ray.new
  238. },
  239. Region3 = {
  240. new = Region3.new
  241. },
  242. Region3int16 = {
  243. new = Region3int16.new
  244. },
  245. Spawn = Spawn,
  246. Stats = Stats,
  247. UDim = {
  248. new = UDim.new
  249. },
  250. UDim2 = {
  251. new = UDim2.new
  252. },
  253. UserSettings = UserSettings,
  254. Vector2 = {
  255. new = Vector2.new
  256. },
  257. Vector2int16 = {
  258. new = Vector2int16.new
  259. },
  260. Vector3 = {
  261. FromAxis = Vector3.FromAxis,
  262. FromNormalId = Vector3.FromNormalId,
  263. new = Vector3.new
  264. },
  265. Vector3int16 = {
  266. new = Vector3int16.new
  267. },
  268. Version = Version,
  269. Wait = Wait,
  270. Workspace = Workspace,
  271. _G = _G,
  272. _VERSION = _VERSION,
  273. assert = assert,
  274. collectgarbage = collectgarbage,
  275. coroutine = {
  276. create = coroutine.create,
  277. resume = coroutine.resume,
  278. running = coroutine.running,
  279. status = coroutine.status,
  280. wrap = coroutine.wrap,
  281. yield = coroutine.yield
  282. },
  283. crash__ = crash__,
  284. delay = delay,
  285. dofile = dofile,
  286. error = error,
  287. game = game,
  288. gcinfo = gcinfo,
  289. getfenv = getfenv,
  290. getmetatable = getmetatable,
  291. ipairs = ipairs,
  292. load = load,
  293. loadfile = loadfile,
  294. loadstring = loadstring,
  295. math = {
  296. abs = math.abs,
  297. acos = math.acos,
  298. asin = math.asin,
  299. atan = math.atan,
  300. atan2 = math.atan2,
  301. ceil = math.ceil,
  302. cos = math.cos,
  303. cosh = math.cosh,
  304. deg = math.deg,
  305. exp = math.exp,
  306. floor = math.floor,
  307. fmod = math.fmod,
  308. frexp = math.frexp,
  309. huge = math.huge,
  310. ldexp = math.ldexp,
  311. log = math.log,
  312. log10 = math.log10,
  313. max = math.max,
  314. min = math.min,
  315. modf = math.modf,
  316. phi = 1.618033988749895,
  317. pi = math.pi,
  318. pow = math.pow,
  319. rad = math.rad,
  320. random = math.random,
  321. randomseed = math.randomseed,
  322. sin = math.sin,
  323. sinh = math.sinh,
  324. sqrt = math.sqrt,
  325. tan = math.tan,
  326. tanh = math.tanh,
  327. tau = 2 * math.pi
  328. },
  329. newproxy = newproxy,
  330. next = next,
  331. pairs = pairs,
  332. pcall = pcall,
  333. print = print,
  334. printidentity = printidentity,
  335. rawequal = rawequal,
  336. rawget = rawget,
  337. rawset = rawset,
  338. select = select,
  339. setfenv = setfenv,
  340. setmetatable = setmetatable,
  341. settings = settings,
  342. shared = shared,
  343. stats = stats,
  344. string = {
  345. byte = string.byte,
  346. char = string.char,
  347. dump = string.dump,
  348. find = string.find,
  349. format = string.format,
  350. gfind = string.gfind,
  351. gmatch = string.gmatch,
  352. gsub = string.gsub,
  353. len = string.len,
  354. lower = string.lower,
  355. match = string.match,
  356. rep = string.rep,
  357. reverse = string.reverse,
  358. sub = string.sub,
  359. upper = string.upper
  360. },
  361. table = {
  362. concat = table.concat,
  363. foreach = table.foreach,
  364. foreachi = table.foreachi,
  365. getn = table.getn,
  366. insert = table.insert,
  367. maxn = table.maxn,
  368. remove = table.remove,
  369. setn = table.setn,
  370. sort = table.sort
  371. },
  372. tick = tick,
  373. time = time,
  374. tonumber = tonumber,
  375. tostring = tostring,
  376. type = type,
  377. unpack = unpack,
  378. version = version,
  379. wait = wait,
  380. workspace = workspace,
  381. xpcall = xpcall,
  382. ypcall = ypcall
  383. }
  384. _ENV.Environment = ...
  385. _ENV.Environment._ENV = _ENV
  386. local _RBX = getfenv()
  387. _ENV._ENV = _ENV
  388. _ENV._RBX = _RBX
  389. _ENV._SessionID = %s
  390. _ENV.Debris = Game:GetService("Debris")
  391. _ENV.InsertService = Game:GetService("InsertService")
  392. _ENV.Lighting = Game:GetService("Lighting")
  393. _ENV.LogService = Game:GetService("LogService")
  394. _ENV.Players = Game:GetService("Players")
  395. _ENV.RunService = Game:GetService("RunService")
  396. _ENV.ReplicatedStorage = Game:GetService("ReplicatedStorage")
  397. _ENV.SoundService = Game:GetService("SoundService")
  398. _ENV.StarterGui = Game:GetService("StarterGui")
  399. _ENV.StarterPack = Game:GetService("StarterPack")
  400. _ENV.TeleportService = Game:GetService("TeleportService")
  401. _ENV.RbxUtility = LoadLibrary("RbxUtility")
  402. if N_ENV then
  403. N_ENV(_ENV)
  404. end
  405. local Module = ...
  406. Module.data = {
  407. listeners = {},
  408. modules = {}
  409. }
  410. Module.metatable = {}
  411. function Module.metatable:__tostring()
  412. return tostring(self.name)
  413. end
  414. function Module.Create(name, source, ...)
  415. local module = Module.Store(name, source)
  416. Module.Initialize(module, ...)
  417. return module
  418. end
  419. function Module.Initialize(module, ...)
  420. local name = module.name
  421. local load_function, message = loadstring(module.source, name)
  422. if load_function then
  423. local success, message = ypcall(setfenv(load_function, _ENV), ...)
  424. if success then
  425. if _ENV.Logger and _ENV.Logger.printf then
  426. _ENV.Logger.printf("Output", "%%s: ready", tostring(name))
  427. end
  428. local listeners = Module.data.listeners
  429. local listener = listeners[name]
  430. if listener then
  431. listeners[name] = nil
  432. listener:fire()
  433. end
  434. return module
  435. elseif _ENV.Logger and _ENV.Logger.printf then
  436. _ENV.Logger.printf("Severe", "Runtime error in module '%%s': %%s", tostring(name), message)
  437. else
  438. print(string.format("runtime error in module '%%s': %%s", tostring(name), message))
  439. end
  440. elseif _ENV.Logger and _ENV.Logger.printf then
  441. _ENV.Logger.printf("Severe", "Syntax error in module '%%s': %%s", tostring(name), message)
  442. else
  443. print(string.format("syntax error in module '%%s': %%s", tostring(name), message))
  444. end
  445. end
  446. function Module.Load(name)
  447. return Module.data.modules[name]
  448. end
  449. function Module.Register(module)
  450. local name = tostring(module)
  451. _ENV[name] = module
  452. Module.data.modules[name] = module
  453. end
  454. function Module.Reload(name, source, ...)
  455. local module = Module.Load(name)
  456. for key in pairs(module) do
  457. module[key] = nil
  458. end
  459. module.name = name
  460. module.source = source
  461. Module.Initialize(module, ...)
  462. return module
  463. end
  464. function Module.Store(name, source)
  465. local module = {}
  466. module.name = name
  467. module.source = source
  468. setmetatable(module, Module.metatable)
  469. Module.Register(module)
  470. return module
  471. end
  472. function Module.WaitForModule(name)
  473. local module = Module.Load(name)
  474. if not module then
  475. local listeners = Module.data.listeners
  476. local listener = listeners[name]
  477. if not listener then
  478. listener = _ENV.RbxUtility.CreateSignal()
  479. listeners[name] = listener
  480. end
  481. listener:wait()
  482. end
  483. end
  484. ]], tostring(session_id))
  485. assert(loadstring(Module.source))(Module)
  486. setmetatable(Module, Module.metatable)
  487. Module.Register(Module)
  488. Module.Create("LuaEnum", [[
  489. LuaEnum.enum_metatable = {
  490. __call = function(self, value)
  491. local valueType = type(value)
  492. if valueType == "table" and getmetatable(value) == LuaEnum.enum_item_metatable then
  493. return value
  494. else
  495. return self[value]
  496. end
  497. end,
  498. __index = function(self, key)
  499. local enumItem = self.ItemsByName[key] or self.ItemsByValue[key]
  500. if enumItem == nil then
  501. local default = self.Default
  502. if default then
  503. Logger.printf("Warning", "%s is not a valid EnumItem, returning default (%s)", Utility.ToString(key), tostring(default))
  504. enumItem = default
  505. else
  506. Logger.errorf(2, "%s is not a valid EnumItem", Utility.ToString(key))
  507. end
  508. end
  509. return enumItem
  510. end,
  511. __tostring = function(self)
  512. return self.Name
  513. end
  514. }
  515. LuaEnum.enum_item_metatable = {
  516. __tostring = function(self)
  517. return self.Enum.Name .. "." .. self.Name
  518. end
  519. }
  520. LuaEnum.init_metatable = {
  521. __call = function(self, items)
  522. local enumItemsByName = {}
  523. local enumItemsByValue = {}
  524. local enum = {
  525. ItemsByName = enumItemsByName,
  526. ItemsByValue = enumItemsByValue,
  527. Name = self[1]
  528. }
  529. local default = items.Default
  530. if default ~= nil then
  531. items.Default = nil
  532. end
  533. for value, name in pairs(items) do
  534. local enumItem = setmetatable({
  535. Enum = enum,
  536. Name = name,
  537. Value = value
  538. }, LuaEnum.enum_item_metatable)
  539. enumItemsByName[name] = enumItem
  540. enumItemsByValue[value] = enumItem
  541. if name == default or value == default then
  542. enum.Default = enumItem
  543. end
  544. end
  545. return setmetatable(enum, LuaEnum.enum_metatable)
  546. end
  547. }
  548. function LuaEnum.new(name)
  549. return setmetatable({name}, LuaEnum.init_metatable)
  550. end
  551. ]])
  552. Module.Create("Logger", [[
  553. Logger.entries = {0}
  554. Logger.MessageType = LuaEnum.new "MessageType" {
  555. "Output",
  556. "Info",
  557. "Warning",
  558. "Severe",
  559. "Error",
  560. Default = "Severe"
  561. }
  562. Logger.MESSAGE_TYPE_SETTINGS = {
  563. { -- Output
  564. Font = "Arial",
  565. TextColor3 = Color3.new(0, 0, 0)
  566. },
  567. { -- Info
  568. Font = "Arial",
  569. TextColor3 = Color3.new(0, 0, 1)
  570. },
  571. { -- Warning
  572. Font = "ArialBold",
  573. TextColor3 = Color3.new(1, 0.5, 0)
  574. },
  575. { -- Severe/Error
  576. Font = "ArialBold",
  577. TextColor3 = Color3.new(1, 0, 0)
  578. }
  579. }
  580. Logger.MAX_ENTRIES = 160
  581. Logger.WARNING_TRACE_ITEM_COUNT = 5
  582. Logger.rbxPrint = getfenv(RbxUtility.CreateSignal).print
  583. function Logger.error(level, message)
  584. message = message .. "\n" .. Logger.StackTraceToString(Logger.GenerateStackTrace(level + 1))
  585. Logger.AddEntry {Logger.MessageType.Error, message}
  586. error(level + 1, message)
  587. end
  588. function Logger.errorf(level, messageFormat, ...)
  589. Logger.error(level + 1, string.format(messageFormat, ...))
  590. end
  591. function Logger.print(messageType, message, level)
  592. messageType = Logger.MessageType(messageType)
  593. local entry = {messageType, message}
  594. Logger.rbxPrint(Logger.EntryToString(entry))
  595. Logger.AddEntry(entry)
  596. if Network and Network.Print then
  597. Network.Print(messageType.Value, message)
  598. end
  599. if level ~= false and messageType.Value >= Logger.MessageType.Warning.Value then
  600. local maxItems
  601. if messageType.Value >= Logger.MessageType.Severe.Value then
  602. maxItems = math.huge
  603. else
  604. maxItems = Logger.WARNING_TRACE_ITEM_COUNT
  605. end
  606. local trace = Logger.GenerateStackTrace((level or 1) + 1, math.huge, 10, maxItems + 1)
  607. local traceLength = #trace
  608. local stackTraceMessage
  609. local suffix = ""
  610. if traceLength > maxItems then
  611. trace[traceLength] = nil
  612. suffix = "\n..."
  613. end
  614. Logger.print("Info", "Stack trace:\n" .. Logger.StackTraceToString(trace) .. suffix .. "\nStack end", false)
  615. end
  616. end
  617. function Logger.printf(messageType, messageFormat, ...)
  618. Logger.print(messageType, string.format(messageFormat, ...), 2)
  619. end
  620. function Logger.AddEntry(entry)
  621. local entries = Logger.entries
  622. if entries[1] >= Logger.MAX_ENTRIES then
  623. local first = entries[2]
  624. local nextFirst = first[2]
  625. first[1] = nil
  626. first[2] = nil
  627. entries[1] = entries[1] - 1
  628. entries[2] = nextFirst
  629. if not nextFirst then
  630. entries[3] = nil
  631. end
  632. end
  633. local last = entries[3]
  634. local node = {entry}
  635. if last then
  636. entries[3] = node
  637. last[2] = node
  638. else
  639. entries[2] = node
  640. entries[3] = node
  641. end
  642. entries[1] = entries[1] + 1
  643. end
  644. function Logger.NodeIterator(list, node)
  645. if node then
  646. node = node[2]
  647. else
  648. node = list[2]
  649. end
  650. if node then
  651. return node, node[1]
  652. end
  653. end
  654. function Logger.EntryToString(entry)
  655. local messageType, message = entry[1], tostring(entry[2])
  656. if messageType and messageType.Value >= Logger.MessageType.Info.Value then
  657. return messageType.Name .. ": " .. message
  658. else
  659. return message
  660. end
  661. end
  662. function Logger.GenerateStackTrace(level, maxLevel, maxTailCalls, maxTraceItems)
  663. level = level + 2
  664. if maxLevel == nil then
  665. maxLevel = math.huge
  666. else
  667. maxLevel = maxLevel + 2
  668. end
  669. maxTailCalls = maxTailCalls or 10
  670. maxTraceItems = maxTraceItems or math.huge
  671. local trace = {}
  672. local numTailCalls = 0
  673. while level <= maxLevel and numTailCalls <= maxTailCalls and #trace < maxTraceItems do
  674. local success, errorMessage = xpcall(function() error("-", level + 1) end, function(...) return ... end)
  675. if errorMessage == "-" then
  676. numTailCalls = numTailCalls + 1
  677. else
  678. if numTailCalls > 0 then
  679. local traceSize = #trace
  680. if traceSize > 0 then
  681. trace[#trace][3] = numTailCalls
  682. end
  683. numTailCalls = 0
  684. end
  685. local script, line = string.match(errorMessage, "(.*):(%d+)")
  686. trace[#trace + 1] = {script, tonumber(line), 0}
  687. end
  688. level = level + 1
  689. end
  690. return trace
  691. end
  692. function Logger.StackTraceToString(trace)
  693. local buffer = {}
  694. for _, data in ipairs(trace) do
  695. buffer[#buffer + 1] = string.format("Script %q, line %d", data[1], data[2])
  696. local numTailCalls = data[3]
  697. if numTailCalls == 1 then
  698. buffer[#buffer + 1] = "... 1 tail call"
  699. elseif numTailCalls > 1 then
  700. buffer[#buffer + 1] = string.format("... %d tail calls", numTailCalls)
  701. end
  702. end
  703. return table.concat(buffer, "\n")
  704. end
  705. function Logger.MessageOutFunc(message, messageType)
  706. if AdvancedGUI and AdvancedGUI.Print then
  707. local messageTypeValue
  708. if messageType == Enum.MessageType.MessageOutput then
  709. local tagName, untaggedMessage = string.match(message, "(%a+): (.*)")
  710. if tagName == "Info" or tagName == "Warning" or tagName == "Severe" then
  711. messageTypeValue = Logger.MessageType[tagName].Value
  712. message = untaggedMessage
  713. else
  714. messageTypeValue = Logger.MessageType.Output.Value
  715. end
  716. else
  717. messageTypeValue = messageType.Value + 1
  718. end
  719. AdvancedGUI.PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], message)
  720. end
  721. end
  722. function print(...)
  723. local args = {...}
  724. local buffer = {}
  725. for index = 1, select("#", ...) do
  726. buffer[index] = tostring(args[index])
  727. end
  728. local message = table.concat(buffer, "\t")
  729. Logger.print("Output", message)
  730. end
  731. LogService.MessageOut:connect(function(message, messageType)
  732. Logger.MessageOutFunc(message, messageType)
  733. end)
  734. ]])
  735. Module.Create("Utility", [=[
  736. math.randomseed(tick())
  737. function Utility.BlockRobloxFilter(text)
  738. return string.gsub(text, ".", "%1\143")
  739. end
  740. function Utility.ExecuteLua(source, ...)
  741. local execute, syntaxErrorMessage = loadstring(source)
  742. if execute then
  743. local success, runtimeErrorMessage = ypcall(setfenv(execute, _ENV), ...)
  744. if not success then
  745. Logger.printf("Severe", "Runtime error in Utility.ExecuteLua: %s", runtimeErrorMessage)
  746. end
  747. else
  748. Logger.printf("Severe", "Syntax error in Utility.ExecuteLua: %s", syntaxErrorMessage)
  749. end
  750. end
  751.  
  752. local function IsBrickColor(object)
  753. local _ = object.Color
  754. end
  755. local function IsCFrame(object)
  756. local _ = object.p
  757. end
  758. local function IsColor3(object)
  759. local _ = object.r
  760. end
  761. local function IsCustom(object)
  762. return object._6kSo06Sum0aZ7HK
  763. end
  764. local function IsInstance(object)
  765. local _ = object.IsA
  766. end
  767. local function IsRay(object)
  768. local _ = object.Origin
  769. end
  770. local function IsVector2(object)
  771. local _ = object.Z
  772. end
  773. local function IsVector3(object)
  774. local _ = object.Z
  775. end
  776. local function IsUDim(object)
  777. local _ = object.Scale
  778. end
  779. local function IsUDim2(object)
  780. IsUDim(object.Y)
  781. end
  782. local function Color3ToString(color)
  783. return string.format("{r = %.6g, g = %.6g, b = %.6g}", color.r, color.g, color.b)
  784. end
  785. local function Vector3ToString(vector)
  786. return string.format("{X = %.7g, Y = %.7g, Z = %.7g}", vector.X, vector.Y, vector.Z)
  787. end
  788. local function UDimToString(udim)
  789. return string.format("{Scale = %.9g, Offset = %i}", udim.Scale, udim.Offset)
  790. end
  791. function Utility.GetRobloxType(value)
  792. local luaType = type(value)
  793. if luaType == "boolean" then
  794. return "Bool"
  795. elseif luaType == "nil" then
  796. return "Object"
  797. elseif luaType == "number" then
  798. return "Number"
  799. elseif luaType == "string" then
  800. return "String"
  801. elseif luaType == "userdata" then
  802. if pcall(IsInstance, value) then
  803. return "Object"
  804. elseif pcall(IsRay, value) then
  805. return "Ray"
  806. elseif pcall(IsCFrame, value) then
  807. return "CFrame"
  808. elseif pcall(IsVector3, value) then
  809. return "Vector3"
  810. elseif pcall(IsBrickColor, value) then
  811. return "BrickColor"
  812. elseif pcall(IsColor3, value) then
  813. return "Color3"
  814. end
  815. end
  816. end
  817. function Utility.ToString(value)
  818. local luaType = type(value)
  819. if luaType == "string" then
  820. return string.format("%q", value)
  821. elseif luaType == "table" then
  822. local metatable = getmetatable(value)
  823. if type(metatable) == "table" then
  824. local success, metatableName = pcall(tostring, metatable)
  825. if not success then
  826. metatableName = "(bad __tostring)"
  827. end
  828. local valueName
  829. success, valueName = pcall(tostring, value)
  830. if not success then
  831. valueName = "(bad __tostring)"
  832. end
  833. return string.format("{...(%s/metatable=%s)}", valueName, metatableName)
  834. elseif metatable ~= nil then
  835. return string.format("{...(%s/metatable=%s)}", tostring(value), Utility.ToString(metatable))
  836. else
  837. return string.format("{...(%s)}", tostring(value))
  838. end
  839. elseif luaType == "userdata" and not pcall(IsCustom, value) then
  840. if pcall(IsInstance, value) then
  841. return Utility.SafeGetFullName(value)
  842. elseif pcall(IsRay, value) then
  843. return string.format("Ray {Origin = %s, Direction = %s}",
  844. Vector3ToString(value.Origin), Vector3ToString(value.Direction))
  845. elseif pcall(IsCFrame, value) then
  846. return string.format("CFrame {Position = %s, Rotation = %s}",
  847. Vector3ToString(value.p), Vector3ToString(Vector3.new(value:toEulerAnglesXYZ()) * math.deg(1)))
  848. elseif pcall(IsVector3, value) then
  849. return string.format("Vector3 %s", Vector3ToString(value))
  850. elseif pcall(IsUDim2, value) then
  851. return string.format("UDim2 {X = %s, Y = %s}", UDimToString(value.X), UDimToString(value.Y))
  852. elseif pcall(IsVector2, value) then
  853. return string.format("Vector2 {X = %.7g, Y = %.7g}", value.X, value.Y)
  854. elseif pcall(IsUDim, value) then
  855. return string.format("UDim %s", UDimToString(value))
  856. elseif pcall(IsBrickColor, value) then
  857. return string.format("BrickColor {Name = %q, Color = %s}", value.Name, Color3ToString(value.Color))
  858. elseif pcall(IsBrickColor, value) then
  859. return string.format("Color3 %s", Color3ToString(value))
  860. else
  861. local stringValue = "(unknown userdata) {tostring(value)}"
  862. Logger.printf("Warning", "Failed to detect type of [%s] while converting to string",
  863. stringValue)
  864. return stringValue
  865. end
  866. else
  867. return tostring(value)
  868. end
  869. end
  870. Utility.UnsafeGetFullName = Game.GetFullName
  871. function Utility.SafeGetFullName(object)
  872. local success, result = pcall(Utility.UnsafeGetFullName, object)
  873. if success then
  874. return result
  875. else
  876. local name = tostring(object)
  877. Logger.printf("Warning", "Invalid permissions for %s:GetFullName() (details: %q)",
  878. name, result)
  879. return name
  880. end
  881. end
  882. function Utility.UnsafeGetProperty(object, key)
  883. return object[key]
  884. end
  885. function Utility.SafeGetProperty(object, key)
  886. local success, result = pcall(Utility.UnsafeGetProperty, object, key)
  887. if success then
  888. return result
  889. else
  890. Logger.printf("Warning", "Invalid permissions for %s[%s] (details: %q)",
  891. Utility.ToString(object), Utility.ToString(key), result)
  892. return nil, true
  893. end
  894. end
  895. Utility.UnsafeIsA = Game.IsA
  896. function Utility.SafeIsA(object, typename)
  897. local success, result = pcall(Utility.UnsafeIsA, object, typename)
  898. if success then
  899. return result
  900. else
  901. Logger.printf("Warning", "Invalid permissions for %s:IsA(%s) (details: %q)",
  902. Utility.ToString(object), Utility.ToString(typename), result)
  903. return false
  904. end
  905. end
  906. -- TODO: deprecate GetProperty and replace uses with SafeGetProperty
  907. function Utility.GetProperty(object, field)
  908. return object[field]
  909. end
  910. function Utility.SetProperty(object, field, value)
  911. object[field] = value
  912. end
  913.  
  914. function Utility.Banish()
  915. if Player then
  916. Utility.Destroy("Magenta")
  917. Network.TransmitServer(string.format("ServerControl.BanishName(%q)", tostring(Player)))
  918. wait(1)
  919. Utility.QuickDisconnect()
  920. end
  921. end
  922. function Utility.CleanLighting()
  923. Lighting.Ambient = Color3.new(0, 0, 0)
  924. Lighting.Brightness = 1
  925. Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
  926. Lighting.ColorShift_Top = Color3.new(0, 0, 0)
  927. Lighting.FogColor = Color3.new(0.75294125080109, 0.75294125080109, 0.75294125080109)
  928. Lighting.FogEnd = 100000
  929. Lighting.FogStart = 0
  930. Lighting.GeographicLatitude = 41.733299255371095
  931. Lighting.GlobalShadows = true
  932. Lighting.OutdoorAmbient = Color3.new(0.5, 0.5, 0.5)
  933. Lighting.Outlines = false
  934. Lighting.ShadowColor = Color3.new(0.70196080207825, 0.70196080207825, 0.72156864404678)
  935. Lighting.TimeOfDay = "14:00:00"
  936. for index, child in ipairs(Lighting:GetChildren()) do
  937. if child:IsA("Sky") then
  938. child:Destroy()
  939. end
  940. end
  941. end
  942. function Utility.CleanWorkspace()
  943. for index, child in ipairs(Workspace:GetChildren()) do
  944. if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child:IsA("Script") or child.ClassName == "Terrain") then
  945. pcall(child.Destroy, child)
  946. end
  947. end
  948. Workspace.Terrain:Clear()
  949. local base = Instance.new("Part")
  950. base.Anchored = true
  951. base.BrickColor = BrickColor.new("Earth green")
  952. base.Locked = true
  953. base.Name = "Base"
  954. base.Size = Vector3.new(512, 1.2, 512)
  955. base.Parent = Workspace
  956. end
  957. function Utility.CleanWorkspaceAndScripts()
  958. for index, child in ipairs(Workspace:GetChildren()) do
  959. if not (Players:GetPlayerFromCharacter(child) or child.ClassName == "Camera" or child.ClassName == "Terrain") then
  960. pcall(child.Destroy, child)
  961. end
  962. end
  963. Workspace.Terrain:Clear()
  964. local base = Instance.new("Part")
  965. base.Anchored = true
  966. base.BrickColor = BrickColor.new("Earth green")
  967. base.Locked = true
  968. base.Name = "Base"
  969. base.Size = Vector3.new(512, 1.2, 512)
  970. base.Parent = Workspace
  971. end
  972. function Utility.CreateDummy(cframe, name, parent)
  973. local model = Instance.new("Model")
  974. model.Archivable = false
  975. model.Name = name
  976. local humanoid = Instance.new("Humanoid", model)
  977. local head = Instance.new("Part", model)
  978. local face = Instance.new("Decal", head)
  979. local head_mesh = Instance.new("SpecialMesh", head)
  980. local torso = Instance.new("Part", model)
  981. local right_arm = Instance.new("Part", model)
  982. local left_arm = Instance.new("Part", model)
  983. local right_leg = Instance.new("Part", model)
  984. local left_leg = Instance.new("Part", model)
  985. local neck = Instance.new("Motor", torso)
  986. local right_shoulder = Instance.new("Motor", torso)
  987. local left_shoulder = Instance.new("Motor", torso)
  988. local right_hip = Instance.new("Motor", torso)
  989. local left_hip = Instance.new("Motor", torso)
  990. head.BrickColor = BrickColor.Yellow()
  991. head.CFrame = cframe * CFrame.new(0, 1.5, 0)
  992. head.FormFactor = "Symmetric"
  993. head.Locked = true
  994. head.Name = "Head"
  995. head.Size = Vector3.new(2, 1, 1)
  996. head.TopSurface = "Smooth"
  997. face.Texture = "rbxasset://textures/face.png"
  998. head_mesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  999. torso.BrickColor = BrickColor.Blue()
  1000. torso.CFrame = cframe
  1001. torso.FormFactor = "Symmetric"
  1002. torso.LeftSurface = "Weld"
  1003. torso.Locked = true
  1004. torso.RightSurface = "Weld"
  1005. torso.Name = "Torso"
  1006. torso.Size = Vector3.new(2, 2, 1)
  1007. right_arm.BrickColor = BrickColor.Yellow()
  1008. right_arm.CanCollide = false
  1009. right_arm.CFrame = cframe * CFrame.new(1.5, 0, 0)
  1010. right_arm.FormFactor = "Symmetric"
  1011. right_arm.Locked = true
  1012. right_arm.Name = "Right Arm"
  1013. right_arm.Size = Vector3.new(1, 2, 1)
  1014. left_arm.BrickColor = BrickColor.Yellow()
  1015. left_arm.CanCollide = false
  1016. left_arm.CFrame = cframe * CFrame.new(-1.5, 0, 0)
  1017. left_arm.FormFactor = "Symmetric"
  1018. left_arm.Locked = true
  1019. left_arm.Name = "Left Arm"
  1020. left_arm.Size = Vector3.new(1, 2, 1)
  1021. right_leg.BrickColor = BrickColor.new("Br. yellowish green")
  1022. right_leg.BottomSurface = "Smooth"
  1023. right_leg.CanCollide = false
  1024. right_leg.CFrame = cframe * CFrame.new(0.5, -2, 0)
  1025. right_leg.FormFactor = "Symmetric"
  1026. right_leg.Locked = true
  1027. right_leg.Name = "Right Leg"
  1028. right_leg.Size = Vector3.new(1, 2, 1)
  1029. right_leg.TopSurface = "Smooth"
  1030. left_leg.BrickColor = BrickColor.new("Br. yellowish green")
  1031. left_leg.BottomSurface = "Smooth"
  1032. left_leg.CanCollide = false
  1033. left_leg.CFrame = cframe * CFrame.new(-0.5, -2, 0)
  1034. left_leg.FormFactor = "Symmetric"
  1035. left_leg.Locked = true
  1036. left_leg.Name = "Left Leg"
  1037. left_leg.Size = Vector3.new(1, 2, 1)
  1038. left_leg.TopSurface = "Smooth"
  1039. neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  1040. neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  1041. neck.Name = "Neck"
  1042. neck.Part0 = torso
  1043. neck.Part1 = head
  1044. right_shoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1045. right_shoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1046. right_shoulder.MaxVelocity = 0.15
  1047. right_shoulder.Name = "Right Shoulder"
  1048. right_shoulder.Part0 = torso
  1049. right_shoulder.Part1 = right_arm
  1050. left_shoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1051. left_shoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1052. left_shoulder.MaxVelocity = 0.15
  1053. left_shoulder.Name = "Left Shoulder"
  1054. left_shoulder.Part0 = torso
  1055. left_shoulder.Part1 = left_arm
  1056. right_hip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1057. right_hip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  1058. right_hip.MaxVelocity = 0.1
  1059. right_hip.Name = "Right Hip"
  1060. right_hip.Part0 = torso
  1061. right_hip.Part1 = right_leg
  1062. left_hip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1063. left_hip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  1064. left_hip.MaxVelocity = 0.1
  1065. left_hip.Name = "Left Hip"
  1066. left_hip.Part0 = torso
  1067. left_hip.Part1 = left_leg
  1068. humanoid.Died:connect(function()
  1069. wait(5)
  1070. model:Destroy()
  1071. end)
  1072. model.Parent = parent
  1073. return model
  1074. end
  1075. function Utility.Crash()
  1076. local function Recurse(x)
  1077. pcall(function() x.DescendantAdded:connect(Recurse) end)
  1078. pcall(Instance.new, "IntValue", x)
  1079. end
  1080. pcall(Recurse, Game)
  1081. end
  1082. function Utility.CreateHoleInFloor()
  1083. if Player then
  1084. local character = Player.Character
  1085. if character then
  1086. local torso = character:FindFirstChild("Torso")
  1087. if torso and torso:IsA("BasePart") then
  1088. Network.TransmitServer([[
  1089. local character, torso = ...
  1090. if character and torso then
  1091. local torsoPosition = torso.CFrame * Vector3.new(0, -2, 0)
  1092. local region = Region3.new(torsoPosition + Vector3.new(-8, -20, -8), torsoPosition + Vector3.new(8, -1, 8))
  1093. for index = 1, 25 do
  1094. if Fragmentation.DamageRegion(region, 8, character) == 0 then
  1095. break
  1096. end
  1097. end
  1098. end]], character, torso)
  1099. end
  1100. end
  1101. end
  1102. end
  1103. function Utility.Destroy(color)
  1104. if Player then
  1105. pcall(function()
  1106. local head, position, view = Utility.FindLocalHead()
  1107. if head then
  1108. Network.TransmitServer(string.format([[
  1109. local base_part = ...
  1110. GraphicalEffects.CrystalRing({base_part = base_part, crystal_color = BrickColor.new(%q)})
  1111. if base_part then
  1112. pcall(function()
  1113. local parent = base_part.Parent
  1114. if parent == Workspace then
  1115. base_part:Destroy()
  1116. else
  1117. for _, child in ipairs(parent:GetChildren()) do
  1118. pcall(Game.Destroy, child)
  1119. end
  1120. end
  1121. end)
  1122. end
  1123. ]], color), head)
  1124. elseif position then
  1125. Network.TransmitServer(string.format([[
  1126. GraphicalEffects.CrystalRing({position = ..., crystal_color = BrickColor.new(%q)})
  1127. ]], color), position)
  1128. end
  1129. end)
  1130. end
  1131. end
  1132. function Utility.Disconnect()
  1133. if Player then
  1134. Utility.Destroy("Bright red")
  1135. wait(1)
  1136. Utility.QuickDisconnect()
  1137. end
  1138. end
  1139. function Utility.FindHumanoidClosestToRay(ray, exlusionList)
  1140. local view = CFrame.new(ray.Origin, ray.Origin + ray.Direction)
  1141. local inverseView = view:inverse()
  1142. local objects = Workspace:GetChildren()
  1143. local numObjects = #objects
  1144. local minDistance = math.huge
  1145. local closestHumanoid, closestTorso, closestTorsoPosition
  1146. for index, object in ipairs(objects) do
  1147. for index, child in ipairs(object:GetChildren()) do
  1148. numObjects = numObjects + 1
  1149. objects[numObjects] = child
  1150. end
  1151. if object.ClassName == "Humanoid" and object.Health > 0 then
  1152. local torso = object.Torso
  1153. if torso and not (exlusionList and exlusionList[torso]) then
  1154. local torsoPosition = torso.Position
  1155. local relativePosition = inverseView * torsoPosition
  1156. local distanceZ = -relativePosition.Z
  1157. if distanceZ > 0 then
  1158. local distance = (inverseView * torsoPosition * Vector3.new(1, 1, 0)).magnitude / distanceZ
  1159. if distance < 0.25 and distance < minDistance then
  1160. closestHumanoid = object
  1161. closestTorso = torso
  1162. closestTorsoPosition = torsoPosition
  1163. minDistance = distance
  1164. end
  1165. end
  1166. end
  1167. end
  1168. end
  1169. return closestHumanoid, closestTorso, closestTorsoPosition, minDistance
  1170. end
  1171. function Utility.FindLocalHead()
  1172. if Player then
  1173. local head, position, view
  1174. pcall(function()
  1175. position = Camera.Focus.p
  1176. view = Camera.CoordinateFrame
  1177. end)
  1178. pcall(function()
  1179. for _, child in ipairs(Workspace:GetChildren()) do
  1180. if Players:GetPlayerFromCharacter(child) == Player then
  1181. for _, child in ipairs(child:GetChildren()) do
  1182. if tostring(child) == "Head" and pcall(assert, pcall(Game.IsA, child, "BasePart")) then
  1183. head = child
  1184. break
  1185. end
  1186. end
  1187. break
  1188. end
  1189. end
  1190. if not head and view then
  1191. local min_distance = math.huge
  1192. local objects = Workspace:GetChildren()
  1193. for _, object in ipairs(objects) do
  1194. local success, is_part = pcall(Game.IsA, object, "BasePart")
  1195. if success and is_part then
  1196. pcall(function()
  1197. local distance = (view:pointToObjectSpace(object.Position) * Vector3.new(1, 1, 0)).magnitude
  1198. if distance < min_distance and distance < 1 then
  1199. min_distance = distance
  1200. head = object
  1201. elseif tostring(object) == "Head" and tostring(object.Parent):lower():match("^" .. tostring
  1202.  
  1203. (Player):lower()) then
  1204. min_distance = 0
  1205. head = object
  1206. end
  1207. end)
  1208. if min_distance < 5e-4 then
  1209. break
  1210. end
  1211. end
  1212. pcall(function()
  1213. if not object:IsA("Camera") then
  1214. for _, child in ipairs(object:GetChildren()) do
  1215. objects[#objects + 1] = child
  1216. end
  1217. end
  1218. end)
  1219. end
  1220. end
  1221. end)
  1222. return head, position, view
  1223. end
  1224. end
  1225. function Utility.GetBuildingTools()
  1226. local backpack = Player:FindFirstChild("Backpack")
  1227. if backpack then
  1228. local moveTool = Instance.new("HopperBin")
  1229. local cloneTool = Instance.new("HopperBin")
  1230. local deleteTool = Instance.new("HopperBin")
  1231. moveTool.BinType = Enum.BinType.GameTool
  1232. cloneTool.BinType = Enum.BinType.Clone
  1233. deleteTool.BinType = Enum.BinType.Hammer
  1234. moveTool.Parent = backpack
  1235. cloneTool.Parent = backpack
  1236. deleteTool.Parent = backpack
  1237. end
  1238. end
  1239. function Utility.GetRainbowRGB(hue)
  1240. local section = hue % 1 * 3
  1241. local secondary = 0.5 * math.pi * (section % 1)
  1242. if section < 1 then
  1243. return 1, 1 - math.cos(secondary), 1 - math.sin(secondary)
  1244. elseif section < 2 then
  1245. return 1 - math.sin(secondary), 1, 1 - math.cos(secondary)
  1246. else
  1247. return 1 - math.cos(secondary), 1 - math.sin(secondary), 1
  1248. end
  1249. end
  1250. function Utility.HSVtoRGB(h, s, v)
  1251. h = (h % 1) * 6
  1252. local f = h % 1
  1253. local p = v * (1 - s)
  1254. local q = v * (1 - s * f)
  1255. local t = v * (1 - s * (1 - f))
  1256. if h < 1 then
  1257. return v, t, p
  1258. elseif h < 2 then
  1259. return q, v, p
  1260. elseif h < 3 then
  1261. return p, v, t
  1262. elseif h < 4 then
  1263. return p, q, v
  1264. elseif h < 5 then
  1265. return t, p, v
  1266. else
  1267. return v, p, q
  1268. end
  1269. end
  1270. function Utility.GetTimestamp()
  1271. local unix_time = tick()
  1272. local time_secs = math.floor(unix_time % 60)
  1273. local time_mins = math.floor(unix_time / 60 % 60)
  1274. local time_hours = math.floor(unix_time / 3600 % 24)
  1275. return string.format("%02i:%02i:%02i", time_hours, time_mins, time_secs)
  1276. end
  1277. function Utility.CaseInsensitivePattern(pattern)
  1278. return string.gsub(pattern, "(%%?)(.)", Utility.CaseInsensitivePatternReplaceFunc)
  1279. end
  1280. function Utility.CaseInsensitivePatternReplaceFunc(percent, letter)
  1281. if percent ~= "" or not letter:match("%a") then
  1282. return percent .. letter
  1283. else
  1284. return "[" .. string.lower(letter) .. string.upper(letter) .. "]"
  1285. end
  1286. end
  1287. function Utility.PingConnections()
  1288. Network.Transmit(".", string.format([[Network.TransmitController(string.format("print(%%q .. (tick() - %s))", "[" .. Network.script_name ..
  1289.  
  1290. "]\t"))]], tick()))
  1291. end
  1292. function Utility.Rejoin()
  1293. TeleportService:Teleport(Game.PlaceId)
  1294. end
  1295. function Utility.QuickDisconnect()
  1296. if Player then
  1297. if Player.Parent then
  1298. pcall(Player.Kick, Player)
  1299. else
  1300. Utility.Crash()
  1301. end
  1302. end
  1303. end
  1304. function Utility.SurroundWithDummies(parent)
  1305. local head, position = Utility.FindLocalHead()
  1306. local center = CFrame.new(position)
  1307. local dummy_count = 13
  1308. for index = 1, dummy_count do
  1309. Utility.CreateDummy(CFrame.new(center * CFrame.Angles(0, math.tau * index / dummy_count, 0) * Vector3.new(0, 0, -30), position), "???",
  1310.  
  1311. parent)
  1312. end
  1313. end
  1314. ]=])
  1315. Module.Create("ChatColor", [[
  1316. ChatColor.COLOR_TABLE = {
  1317. BrickColor.new("Bright red"),
  1318. BrickColor.new("Bright blue"),
  1319. BrickColor.new("Earth green"),
  1320. BrickColor.new("Bright violet"),
  1321. BrickColor.new("Bright orange"),
  1322. BrickColor.new("Bright yellow"),
  1323. BrickColor.new("Light reddish violet"),
  1324. BrickColor.new("Brick yellow")
  1325. }
  1326. function ChatColor.Get(name)
  1327. return ChatColor.COLOR_TABLE[ChatColor.GetId(name) + 1]
  1328. end
  1329. function ChatColor.GetId(name)
  1330. local length = #name
  1331. local modifier = (length % 2 == 0) and 1 or 0
  1332. local value = 0
  1333. for index = 1, length do
  1334. if (length - index + modifier) % 4 < 2 then
  1335. value = value + string.byte(name, index)
  1336. else
  1337. value = value - string.byte(name, index)
  1338. end
  1339. end
  1340. return value % 8
  1341. end
  1342. ]])
  1343. Module.Create("TaskScheduler", [[
  1344. local currentTime = 0
  1345. local pairs = pairs
  1346. local rbx_coroutine_create = coroutine.create
  1347. local rbx_coroutine_resume = coroutine.resume
  1348. local rbx_Wait = Wait
  1349. local rbx_ypcall = ypcall
  1350. local threads, swapThreads = {}, {}
  1351. local function StartCoroutine(func, delay, ...)
  1352. if delay > 0 then
  1353. rbx_Wait(delay)
  1354. end
  1355. local success, message = rbx_ypcall(func, ...)
  1356. if not success then
  1357. Logger.printf("Severe", "Error in a TaskScheduler coroutine: %s", message)
  1358. end
  1359. end
  1360. function TaskScheduler.GetCurrentTime()
  1361. return currentTime
  1362. end
  1363. function TaskScheduler.MainLoop(stepTime)
  1364. currentTime = currentTime + stepTime
  1365. threads, swapThreads = swapThreads, threads
  1366. local threshold = -0.5 * stepTime
  1367. for thread, resumeTime in pairs(swapThreads) do
  1368. local remainingTime = currentTime - resumeTime
  1369. if remainingTime >= threshold then
  1370. swapThreads[thread] = nil
  1371. local success, message = coroutine.resume(thread, remainingTime, currentTime)
  1372. if not success then
  1373. Logger.printf("Severe", "Error in a TaskScheduler custom thread: %s", message)
  1374. end
  1375. end
  1376. end
  1377. threads, swapThreads = swapThreads, threads
  1378. for thread, resumeTime in pairs(swapThreads) do
  1379. threads[thread], swapThreads[thread] = resumeTime, nil
  1380. end
  1381. end
  1382. -- TODO: add stack trace info to scheduling functions?
  1383. function TaskScheduler.Schedule(t, f, ...)
  1384. coroutine.resume(coroutine.create(StartCoroutine), f, t, ...)
  1385. end
  1386. function TaskScheduler.Start(f, ...)
  1387. coroutine.resume(coroutine.create(StartCoroutine), f, 0, ...)
  1388. end
  1389. function TaskScheduler.ScheduleCustomThread(t, f)
  1390. threads[coroutine.create(f)] = currentTime + t
  1391. end
  1392. function TaskScheduler.Wait(duration)
  1393. duration = tonumber(duration) or 0
  1394. threads[coroutine.running()] = currentTime + duration
  1395. local remainingTime, currentTime = coroutine.yield()
  1396. return remainingTime + duration, currentTime
  1397. end
  1398. local success, player = Players.LocalPlayer
  1399. if success and player then
  1400. RunService.RenderStepped:connect(function()
  1401. TaskScheduler.MainLoop(1 / 60)
  1402. end)
  1403. else
  1404. RunService.Stepped:connect(function()
  1405. TaskScheduler.MainLoop(1 / 30)
  1406. end)
  1407. end
  1408. ]])
  1409. Module.Create("UserInterface", [=[
  1410. local CONTROLLER = (...)
  1411. Player = Players.LocalPlayer
  1412. Mouse = Player:GetMouse()
  1413. Camera = Workspace.CurrentCamera
  1414. UserInterface.activity_update_frequency = 5
  1415. UserInterface.consequtive_long_message_count = 0
  1416. UserInterface.previous_message_time = -math.huge
  1417. UserInterface.commands = {}
  1418. UserInterface.hotkeys = {}
  1419. UserInterface.key_down_time = {}
  1420. UserInterface.key_up_time = {}
  1421. UserInterface.player_name = tostring(Player)
  1422. UserInterface.last_seen_time = tick()
  1423. function UserInterface.ActivateHotkey(key)
  1424. local callback = UserInterface.hotkeys[key]
  1425. if callback then
  1426. TaskScheduler.Start(callback)
  1427. end
  1428. end
  1429. function UserInterface.Chat(message)
  1430. local message_length = #message
  1431. local echo = message_length > 403 and (string.sub(message, 1, 400) .. "...") or message
  1432. if CONTROLLER then
  1433. if string.sub(message, 1, 1) == "/" then
  1434. Logger.printf("Output", "> %s", string.sub(echo, 2))
  1435. UserInterface.ExecuteCommand(string.sub(message, 2))
  1436. else
  1437. PlayerControl.Chat(message)
  1438. AdvancedGUI.PrintChatLog(UserInterface.player_name, echo)
  1439. end
  1440. else
  1441. local chat_visible = true
  1442. if message_length > 500 then
  1443. local current_time = tick()
  1444. if current_time - UserInterface.previous_message_time > 2.2 then
  1445. UserInterface.consequtive_long_message_count = 1
  1446. else
  1447. local count = UserInterface.consequtive_long_message_count + 1
  1448. UserInterface.consequtive_long_message_count = count
  1449. if count == 2 then
  1450. echo = "<BLOCKED MESSAGES>"
  1451. elseif count > 2 then
  1452. chat_visible = false
  1453. end
  1454. end
  1455. UserInterface.previous_message_time = current_time
  1456. end
  1457. if chat_visible then
  1458. Network.TransmitController(string.format("AdvancedGUI.PrintChatLog(%q, %q)", UserInterface.player_name, echo))
  1459. end
  1460. if string.sub(message, 1, 1) == "/" then
  1461. UserInterface.ExecuteCommand(string.sub(message, 2))
  1462. end
  1463. end
  1464. end
  1465. function UserInterface.ExecuteCommand(command, args)
  1466. command = tostring(command)
  1467. local commandFunc
  1468. for pattern, func in pairs(UserInterface.commands) do
  1469. local match = string.match(command, pattern) or string.match(command .. " ", pattern)
  1470. if match then
  1471. args = args and tostring(args) or match
  1472. commandFunc = func
  1473. break
  1474. end
  1475. end
  1476. if commandFunc then
  1477. TaskScheduler.Start(commandFunc, args)
  1478. end
  1479. end
  1480. function UserInterface.IsKeyDown(key)
  1481. local time_down, time_up = UserInterface.key_down_time[key], UserInterface.key_up_time[key]
  1482. return time_down and (not time_up or time_down >= time_up)
  1483. end
  1484. function UserInterface.MainLoop()
  1485. local idle_time = tick() - UserInterface.last_seen_time
  1486. Network.TransmitServer(string.format("local _=ServerControl if _ then local _=_.player_data if _ then _[%q]={%q,%s}end end", tostring(Player),
  1487.  
  1488. Utility.GetTimestamp(), tostring(idle_time)))
  1489. TaskScheduler.Wait(UserInterface.activity_update_frequency)
  1490. end
  1491. function UserInterface.NonIdle()
  1492. UserInterface.last_seen_time = tick()
  1493. end
  1494. function UserInterface.PressKey(key)
  1495. UserInterface.key_down_time[key] = time()
  1496. UserInterface.NonIdle()
  1497. UserInterface.ActivateHotkey(key)
  1498. end
  1499. function UserInterface.ReleaseKey(key)
  1500. UserInterface.key_up_time[key] = time()
  1501. UserInterface.NonIdle()
  1502. end
  1503. function UserInterface.SetCommand(name, commandFunc)
  1504. local nameType = type(name)
  1505. if nameType == "table" then
  1506. for _, alias in ipairs(name) do
  1507. UserInterface.SetCommand(alias, commandFunc)
  1508. end
  1509. elseif nameType == "string" then
  1510. local commandFuncType = type(commandFunc)
  1511. if commandFunc ~= nil and commandFuncType ~= "function" then
  1512. Logger.printf("Severe", "Bad argument #2 to UserInterface.SetCommand (function or nil expected, got %s)", commandFuncType)
  1513. return
  1514. end
  1515. local pattern = "^" .. string.lower(name) .. (string.find(name, "[%w_]$") and "([^%w_].*)" or "(.*)")
  1516. UserInterface.commands[pattern] = commandFunc
  1517. else
  1518. Logger.printf("Severe", "Bad argument #1 to UserInterface.SetCommand (string or table expected, got %s)", nameType)
  1519. return
  1520. end
  1521. end
  1522. function UserInterface.SetHotkey(key, callback)
  1523. local keyType = type(key)
  1524. if keyType ~= "string" then
  1525. Logger.printf("Severe", "Bad argument #1 to UserInterface.SetHotkey (string expected, got %s)", keyType)
  1526. return
  1527. end
  1528. local callbackType = type(callback)
  1529. if callback ~= nil and callbackType ~= "function" then
  1530. Logger.printf("Severe", "Bad argument #2 to UserInterface.SetHotkey (function or nil expected, got %s)", callbackType)
  1531. return
  1532. end
  1533. UserInterface.hotkeys[key] = callback
  1534. end
  1535. if Mouse then
  1536. Mouse.KeyDown:connect(UserInterface.PressKey)
  1537. Mouse.KeyUp:connect(UserInterface.ReleaseKey)
  1538. Mouse.Move:connect(UserInterface.NonIdle)
  1539. Mouse.WheelBackward:connect(UserInterface.NonIdle)
  1540. Mouse.WheelForward:connect(UserInterface.NonIdle)
  1541. else
  1542. print("This player got kicked before a mouse was created")
  1543. end
  1544. function UserInterface.FixChattedConnection()
  1545. local connection = UserInterface.chattedConnection
  1546. if not connection or not connection.connected then
  1547. UserInterface.chattedConnection = Player.Chatted:connect(function(...)
  1548. local success, errorMessage = ypcall(UserInterface.Chat, ...)
  1549. if not success then
  1550. Logger.printf("Severe", "Error in UserInterface.Chat: %s", errorMessage)
  1551. end
  1552. end)
  1553. end
  1554. end
  1555. UserInterface.FixChattedConnection()
  1556. Player.AncestryChanged:connect(function()
  1557. wait()
  1558. UserInterface.FixChattedConnection()
  1559. end)
  1560. function UserInterface.QuickPrint(messageText)
  1561. Notification.Show(Utility.BlockRobloxFilter(messageText))
  1562. end
  1563. UserInterface.SetCommand("sethintcolor", function(args)
  1564. local red, green, blue = string.match(args, "%s*([^,%s]+)%s*,%s*([^,%s]+)%s*,%s*([^,%s]+)%s*")
  1565. if red and green and blue then
  1566. local red_num, green_num, blue_num = tonumber(red), tonumber(green), tonumber(blue)
  1567. if red_num and green_num and blue_num then
  1568. local color = Color3.new(red_num, green_num, blue_num)
  1569. Notification.color = color
  1570. Network.TransmitServer([[
  1571. local playerName, color = ...
  1572. local player = ServerControl.GetPlayer(playerName)
  1573. player:WaitForDataReady()
  1574. player:SaveString("Notification.color", Serializer.EncodeColor3(color))
  1575. ]], Player.Name, color)
  1576. end
  1577. end
  1578. end)
  1579. TaskScheduler.ScheduleCustomThread(0, function()
  1580. Module.WaitForModule("Network")
  1581. while true do
  1582. UserInterface.MainLoop()
  1583. end
  1584. end)
  1585. ]=], true)
  1586. Module.Store("Serializer", [=[
  1587. Serializer.NAN = math.abs(0 / 0)
  1588.  
  1589. function Serializer.DecodeFloatArray(metadata_size, lookup, data, index)
  1590. local metadata_bytes = math.ceil(metadata_size * 0.25)
  1591. local metadata = {string.byte(data, index, index + metadata_bytes - 1)}
  1592. local components = {}
  1593. local start_index = index
  1594. index = index + metadata_bytes
  1595. for byte_index, byte in ipairs(metadata) do
  1596. local last_offset = 3
  1597. if byte_index == metadata_bytes then
  1598. last_offset = (metadata_size - 1) % 4
  1599. end
  1600. for value_offset = 0, last_offset do
  1601. local value_code = byte * 0.25 ^ value_offset % 4
  1602. value_code = value_code - value_code % 1
  1603. if value_code == 0 then
  1604. table.insert(components, Serializer.DecodeFloat32(string.byte(data, index, index + 3)))
  1605. index = index + 4
  1606. else
  1607. table.insert(components, lookup[value_code])
  1608. end
  1609. end
  1610. end
  1611. return components, index - start_index
  1612. end
  1613. function Serializer.EncodeFloatArray(values, common)
  1614. local lookup = {[common[1]] = 1, [common[2]] = 2, [common[3]] = 3}
  1615. local value_count = #values
  1616. local metadata_bytes = math.ceil(value_count * 0.25)
  1617. local metadata = {}
  1618. local buffer = {}
  1619. for byte_index = 1, metadata_bytes do
  1620. local last_offset = 3
  1621. if byte_index == metadata_bytes then
  1622. last_offset = (value_count - 1) % 4
  1623. end
  1624. local metadata_byte = 0
  1625. local offset_multiplier = 1
  1626. local byte_offset = (byte_index - 1) * 4 + 1
  1627. for value_offset = 0, last_offset do
  1628. local value_index = byte_offset + value_offset
  1629. local value = values[value_index]
  1630. local code = lookup[value] or 0
  1631. metadata_byte = metadata_byte + code * offset_multiplier
  1632. offset_multiplier = offset_multiplier * 4
  1633. if code == 0 then
  1634. table.insert(buffer, Serializer.EncodeFloat32(value))
  1635. end
  1636. end
  1637. metadata[byte_index] = string.char(metadata_byte)
  1638. end
  1639. return table.concat(metadata) .. table.concat(buffer)
  1640. end
  1641.  
  1642. function Serializer.DecodeColor3(data, index)
  1643. local components, size = Serializer.DecodeFloatArray(3, {0, 0.5, 1}, data, index)
  1644. return Color3.new(unpack(components)), size
  1645. end
  1646. function Serializer.DecodeFloat32(b0, b1, b2, b3)
  1647. local b2_low = b2 % 128
  1648. local mantissa = b0 + (b1 + b2_low * 256) * 256
  1649. local exponent = (b2 - b2_low) / 128 + b3 % 128 * 2
  1650. local number
  1651. if mantissa == 0 then
  1652. if exponent == 0 then
  1653. number = 0
  1654. elseif exponent == 0xFF then
  1655. number = math.huge
  1656. else
  1657. number = 2 ^ (exponent - 127)
  1658. end
  1659. elseif exponent == 255 then
  1660. number = Serializer.NAN
  1661. else
  1662. number = (1 + mantissa / 8388608) * 2 ^ (exponent - 127)
  1663. end
  1664. if b3 >= 128 then
  1665. return -number
  1666. else
  1667. return number
  1668. end
  1669. end
  1670. function Serializer.EncodeColor3(color3)
  1671. return Serializer.EncodeFloatArray({color3.r, color3.g, color3.b}, {0, 0.5, 1})
  1672. end
  1673. function Serializer.EncodeFloat32(number)
  1674. if number == 0 then
  1675. if 1 / number > 0 then
  1676. return "\0\0\0\0"
  1677. else
  1678. return "\0\0\0\128"
  1679. end
  1680. elseif number ~= number then
  1681. if string.sub(tostring(number), 1, 1) == "-" then
  1682. return "\255\255\255\255"
  1683. else
  1684. return "\255\255\255\127"
  1685. end
  1686. elseif number == math.huge then
  1687. return "\0\0\128\127"
  1688. elseif number == -math.huge then
  1689. return "\0\0\128\255"
  1690. else
  1691. local b3 = 0
  1692. if number < 0 then
  1693. number = -number
  1694. b3 = 128
  1695. end
  1696. local mantissa, exponent = math.frexp(number)
  1697. exponent = exponent + 126
  1698. if exponent < 0 then
  1699. return "\0\0\0" .. string.char(b3)
  1700. elseif exponent >= 255 then
  1701. return "\0\0\128" .. string.char(b3 + 0x7F)
  1702. else
  1703. local fraction = mantissa * 16777216 - 8388608 + 0.5
  1704. fraction = fraction - fraction % 1
  1705. local exponent_low = exponent % 2
  1706. local b0 = fraction % 256
  1707. local b1 = fraction % 65536
  1708. local b2 = (fraction - b1) / 65536 + exponent_low * 128
  1709. b1 = (b1 - b0) / 256
  1710. b3 = b3 + (exponent - exponent_low) / 2
  1711. return string.char(b0, b1, b2, b3)
  1712. end
  1713. end
  1714. end
  1715. ]=])
  1716. Module.Create("Notification", [=[
  1717. Notification.list = {}
  1718. Notification.color = Color3.new(0, 0, 0)
  1719. TaskScheduler.Start(function()
  1720. Module.WaitForModule("Network")
  1721. Network.TransmitServer([[
  1722. local playerName = ...
  1723. local player = ServerControl.GetPlayer(playerName)
  1724. player:WaitForDataReady()
  1725. local colorData = player:LoadString("Notification.color")
  1726. if colorData ~= "" then
  1727. Network.Transmit("^" .. playerName .. "$", "Notification.color = ...", Serializer.DecodeColor3(player:LoadString("Notification.color"), 1))
  1728. end
  1729. ]], Player.Name)
  1730. end)
  1731. Notification.font = Enum.Font.ArialBold
  1732. Notification.fontSize = Enum.FontSize.Size14
  1733. Notification.maxSize = UDim2.new(0, 500, 0, 500)
  1734. Notification.offset = -135
  1735. Notification.padding = 24
  1736. Notification.showTime = 5
  1737. Notification.spacing = 5
  1738. Notification.stayFactor = 0.05
  1739. Notification.tweenTime = 0.3
  1740. function Notification.Animate()
  1741. local notifications = Notification.list
  1742. local notificationCount = #notifications
  1743. if notificationCount ~= 0 then
  1744. local sessionTime = tick()
  1745. local offset = Notification.offset
  1746. local padding = Notification.padding
  1747. local spacing = Notification.spacing
  1748. local tweenTime = Notification.tweenTime
  1749. local cameraPart = Notification.cameraPart
  1750. if cameraPart.Parent ~= Camera then
  1751. Notification.CreateCameraPart()
  1752. cameraPart = Notification.cameraPart
  1753. end
  1754. local billboardGui = Notification.billboardGui
  1755. if billboardGui.Parent ~= cameraPart then
  1756. Notification.CreateBillboardGui()
  1757. billboardGui = Notification.billboardGui
  1758. end
  1759. local rootFrame = Notification.rootFrame
  1760. if rootFrame.Parent ~= billboardGui then
  1761. Notification.CreateRootFrame()
  1762. rootFrame = Notification.rootFrame
  1763. end
  1764. -- cameraPart.CFrame = Camera.CoordinateFrame * CFrame.new(0, 0, -256)
  1765. -- billboardGui.Size = UDim2.new(0, Mouse.ViewSizeX, 0, Mouse.ViewSizeY)
  1766. local cameraCFrame = CFrame.new(Camera.CoordinateFrame.p, Camera.Focus.p) -- camera.CoordinateFrame
  1767. local viewSizeX, viewSizeY = Mouse.ViewSizeX, Mouse.ViewSizeY
  1768. local viewSizeUDim2 = UDim2.new(0, viewSizeX, 0, viewSizeY)
  1769. billboardGui.SizeOffset = Vector2.new()
  1770. if viewSizeX ~= 0 and viewSizeY ~= 0 then
  1771. billboardGui.Size = viewSizeUDim2
  1772. end
  1773. billboardGui.StudsOffset = (cameraCFrame - cameraCFrame.p):inverse() * cameraCFrame.p - Vector3.new(0, 0, 1)
  1774. rootFrame.Size = viewSizeUDim2
  1775. billboardGui.SizeOffset = Vector2.new(0.5 / viewSizeX, 0.5 / viewSizeY)
  1776. local notificationIndex = 1
  1777. while notificationIndex <= notificationCount do
  1778. local notification = notifications[notificationIndex]
  1779. local frame = notification[5]
  1780. if not frame or frame.Parent ~= rootFrame then
  1781. frame = Instance.new("Frame")
  1782. frame.BackgroundColor3 = Notification.color
  1783. frame.BorderSizePixel = 0
  1784. frame.ClipsDescendants = true
  1785. frame.Visible = false
  1786. frame.ZIndex = 10
  1787. notification[5] = frame
  1788. frame.Parent = rootFrame
  1789. end
  1790. local textLabel = notification[6]
  1791. if not textLabel or textLabel.Parent ~= frame then
  1792. textLabel = Instance.new("TextLabel")
  1793. textLabel.BackgroundTransparency = 1
  1794. textLabel.BorderSizePixel = 0
  1795. textLabel.Font = Notification.font
  1796. textLabel.FontSize = Notification.fontSize
  1797. textLabel.TextColor3 = Color3.new(1, 1, 1)
  1798. textLabel.TextWrapped = true
  1799. textLabel.ZIndex = 10
  1800. textLabel.Parent = frame
  1801. notification[6] = textLabel
  1802. end
  1803. frame.BackgroundColor3 = Notification.color
  1804. textLabel.Font = Notification.font
  1805. textLabel.FontSize = Notification.fontSize
  1806. local message, creationTime, textBounds, showTime = unpack(notification)
  1807. local previousNotification = notifications[notificationIndex + 1]
  1808. if not creationTime then
  1809. creationTime = sessionTime
  1810. textLabel.Size = Notification.maxSize
  1811. textLabel.Text = message
  1812. textBounds = textLabel.TextBounds
  1813. textLabel.Size = UDim2.new(0, textBounds.X, 0, textBounds.Y)
  1814. notification[2] = creationTime
  1815. notification[3] = textBounds
  1816. showTime = Notification.showTime + #message * Notification.stayFactor
  1817. if previousNotification then
  1818. local previousCreationTime = previousNotification[2]
  1819. local previousShowTime = previousNotification[4]
  1820. if previousCreationTime and previousShowTime then
  1821. local minimumShowTime = previousShowTime + previousCreationTime - creationTime
  1822. if minimumShowTime and minimumShowTime > showTime then
  1823. showTime = minimumShowTime
  1824. end
  1825. end
  1826. end
  1827. notification[4] = showTime
  1828. end
  1829. if notificationIndex == 1 then
  1830. offset = offset - (textBounds.Y + padding) * 0.5
  1831. end
  1832. local lifeTime = sessionTime - creationTime
  1833. local visible = true
  1834. if lifeTime < tweenTime then
  1835. local progress = 1 - math.cos(0.5 * math.pi * lifeTime / tweenTime)
  1836. local sizeX = (textBounds.X + padding) * progress
  1837. local sizeY = textBounds.Y + padding
  1838. frame.BackgroundTransparency = 0.3 + 0.7 * (1 - progress)
  1839. textLabel.TextTransparency = 1 - progress
  1840. frame.Position = UDim2.new(0.5, -0.5 * sizeX, 1, offset - 0.5 * sizeY)
  1841. textLabel.Position = UDim2.new(0, -0.5 * (textBounds.X - sizeX), 0, -0.5 * (textBounds.Y - sizeY))
  1842. frame.Size = UDim2.new(0, sizeX, 0, sizeY)
  1843. elseif lifeTime < showTime + tweenTime then
  1844. local sizeX = textBounds.X + padding
  1845. local sizeY = textBounds.Y + padding
  1846. frame.BackgroundTransparency = 0.3
  1847. textLabel.TextTransparency = 0
  1848. frame.Position = UDim2.new(0.5, -0.5 * sizeX, 1, offset - 0.5 * sizeY)
  1849. textLabel.Position = UDim2.new(0, -0.5 * (textBounds.X - sizeX), 0, -0.5 * (textBounds.Y - sizeY))
  1850. frame.Size = UDim2.new(0, sizeX, 0, sizeY)
  1851. elseif lifeTime < showTime + tweenTime * 2 then
  1852. local progress = 1 - math.cos(0.5 * math.pi * (lifeTime - showTime - tweenTime) / tweenTime)
  1853. local sizeX = textBounds.X + padding
  1854. local sizeY = (textBounds.Y + padding) * (1 - progress)
  1855. frame.BackgroundTransparency = 0.3 + 0.7 * progress
  1856. textLabel.TextTransparency = progress
  1857. frame.Position = UDim2.new(0.5, -0.5 * sizeX, 1, offset - 0.5 * sizeY)
  1858. textLabel.Position = UDim2.new(0, -0.5 * (textBounds.X - sizeX), 0, -0.5 * (textBounds.Y - sizeY))
  1859. frame.Size = UDim2.new(0, sizeX, 0, sizeY)
  1860. else
  1861. table.remove(notifications, notificationIndex)
  1862. notificationCount = notificationCount - 1
  1863. visible = false
  1864. end
  1865. frame.Visible = visible
  1866. if visible then
  1867. notificationIndex = notificationIndex + 1
  1868. if previousNotification then
  1869. local previousTextBounds = previousNotification[3]
  1870. if previousTextBounds then
  1871. offset = offset - previousTextBounds.Y * 0.5
  1872. end
  1873. offset = offset - (textBounds.Y * 0.5 + padding + spacing)
  1874. end
  1875. end
  1876. end
  1877. end
  1878. end
  1879. function Notification.CreateBillboardGui()
  1880. local billboardGui = Instance.new("BillboardGui")
  1881. billboardGui.Adornee = Notification.cameraPart
  1882. billboardGui.AlwaysOnTop = true
  1883. Notification.billboardGui = billboardGui
  1884. Notification.CreateRootFrame()
  1885. billboardGui.Parent = Notification.cameraPart
  1886. end
  1887. function Notification.CreateCameraPart()
  1888. local cameraPart = Instance.new("Part")
  1889. cameraPart.Anchored = true
  1890. cameraPart.BottomSurface = "Smooth"
  1891. cameraPart.CanCollide = false
  1892. cameraPart.FormFactor = "Custom"
  1893. cameraPart.Locked = true
  1894. cameraPart.Size = Vector3.new(0.2, 0.2, 0.2)
  1895. cameraPart.TopSurface = "Smooth"
  1896. cameraPart.Transparency = 1
  1897. Notification.cameraPart = cameraPart
  1898. Notification.CreateBillboardGui()
  1899. cameraPart.Parent = Camera
  1900. end
  1901. function Notification.CreateRootFrame()
  1902. local rootFrame = Instance.new("Frame")
  1903. rootFrame.BackgroundTransparency = 1
  1904. rootFrame.BorderSizePixel = 0
  1905. rootFrame.ZIndex = 10
  1906. Notification.rootFrame = rootFrame
  1907. rootFrame.Parent = Notification.billboardGui
  1908. end
  1909. function Notification.Show(message)
  1910. table.insert(Notification.list, 1, {message})
  1911. end
  1912.  
  1913. Notification.CreateCameraPart()
  1914.  
  1915. RunService.RenderStepped:connect(function()
  1916. Notification.Animate()
  1917. end)
  1918. Camera.Changed:connect(function()
  1919. Notification.Animate()
  1920. end)
  1921. ]=])
  1922. Module.Create("PyramidCharacter", [[
  1923. local stock_triangle = Instance.new("WedgePart")
  1924. stock_triangle.Anchored = true
  1925. stock_triangle.BottomSurface = "Smooth"
  1926. stock_triangle.FormFactor = "Custom"
  1927. stock_triangle.Locked = true
  1928. stock_triangle.TopSurface = "Smooth"
  1929. local stock_triangle_mesh = Instance.new("SpecialMesh", stock_triangle)
  1930. stock_triangle_mesh.MeshType = "Wedge"
  1931. local triangles = {}
  1932. function PyramidCharacter.CreateTriangle(v1, v2, v3, properties, parent, index)
  1933. local triangleInfo = triangles[index]
  1934. local side1 = (v1 - v2).magnitude
  1935. local side2 = (v2 - v3).magnitude
  1936. local side3 = (v3 - v1).magnitude
  1937. local sqrside1 = side1 * side1
  1938. local sqrside2 = side2 * side2
  1939. local sqrside3 = side3 * side3
  1940. if sqrside3 + sqrside1 == sqrside2 then
  1941. v1, v2, v3 = v1, v2, v3
  1942. elseif sqrside1 + sqrside2 == sqrside3 then
  1943. v1, v2, v3 = v2, v3, v1
  1944. elseif sqrside2 + sqrside3 == sqrside1 then
  1945. v1, v2, v3 = v3, v1, v2
  1946. elseif sqrside1 >= sqrside2 and sqrside1 >= sqrside3 then
  1947. v1, v2, v3 = v1, v2, v3
  1948. elseif sqrside2 >= sqrside3 and sqrside2 >= sqrside1 then
  1949. v1, v2, v3 = v2, v3, v1
  1950. else
  1951. v1, v2, v3 = v3, v1, v2
  1952. end
  1953. local model, part1, part2, mesh1, mesh2
  1954. if triangleInfo then
  1955. model, part1, part2, mesh1, mesh2 = unpack(triangleInfo)
  1956. if not (model.Parent == parent and part1.Parent == model and part2.Parent == model and mesh1.Parent == part1 and mesh2.Parent == part2) then
  1957. if model.Parent then
  1958. model:Destroy()
  1959. end
  1960. model = nil
  1961. end
  1962. else
  1963. triangleInfo = {}
  1964. triangles[index] = triangleInfo
  1965. end
  1966. if not model then
  1967. model = Instance.new("Model")
  1968. part1 = stock_triangle:Clone()
  1969. part2 = stock_triangle:Clone()
  1970. mesh1 = part1.Mesh
  1971. mesh2 = part2.Mesh
  1972. part1.Parent = model
  1973. part2.Parent = model
  1974. triangleInfo[1] = model
  1975. triangleInfo[2] = part1
  1976. triangleInfo[3] = part2
  1977. triangleInfo[4] = mesh1
  1978. triangleInfo[5] = mesh2
  1979. end
  1980. for key, value in pairs(properties) do
  1981. part1[key] = value
  1982. part2[key] = value
  1983. end
  1984. local cframe = CFrame.new(v1, v2)
  1985. local relpos = cframe:pointToObjectSpace(v3)
  1986. cframe = cframe * CFrame.fromEulerAnglesXYZ(0, 0, -math.atan2(relpos.x, relpos.y))
  1987. local rel1 = cframe:pointToObjectSpace(v1)
  1988. local rel2 = cframe:pointToObjectSpace(v2)
  1989. local rel3 = cframe:pointToObjectSpace(v3)
  1990. local height = rel3.y
  1991. local width1 = rel3.z
  1992. local width2 = rel2.z - rel3.z
  1993. local relcenter1 = Vector3.new(0, height / 2, width1 / 2)
  1994. local center1 = cframe:pointToWorldSpace(relcenter1)
  1995. local relcenter2 = Vector3.new(0, height / 2, width2 / 2 + width1)
  1996. local center2 = cframe:pointToWorldSpace(relcenter2)
  1997. height = math.abs(height)
  1998. width1 = math.abs(width1)
  1999. width2 = math.abs(width2)
  2000. if not part1.Anchored then
  2001. part1.Anchored = true
  2002. end
  2003. part1.Size = Vector3.new(0.2, height, width1)
  2004. part1.CFrame = cframe * CFrame.fromEulerAnglesXYZ(0, math.pi, 0) - cframe.p + center1
  2005. mesh1.Scale = Vector3.new(0, height / part1.Size.y, width1 / part1.Size.z)
  2006. if not part2.Anchored then
  2007. part2.Anchored = true
  2008. end
  2009. part2.Size = Vector3.new(0.2, height, width1)
  2010. part2.CFrame = cframe - cframe.p + center2
  2011. mesh2.Scale = Vector3.new(0, height / part1.Size.y, width2 / part2.Size.z)
  2012. model.Parent = parent
  2013. return model
  2014. end
  2015. PyramidCharacter.head_properties = {BrickColor = BrickColor.new(Color3.new(1, 1, 1)), Transparency = 0.5}
  2016. PyramidCharacter.head_radius = math.pi
  2017. PyramidCharacter.center = CFrame.new(0, 10, 0)
  2018. PyramidCharacter.point1 = Vector3.new()
  2019. PyramidCharacter.point2 = Vector3.new()
  2020. PyramidCharacter.point3 = Vector3.new()
  2021. PyramidCharacter.point4 = Vector3.new()
  2022. PyramidCharacter.core_mesh_scale = Vector3.new(0.833, 0.833, 0.833)
  2023. PyramidCharacter.visible = false
  2024. function PyramidCharacter.Teleport(location)
  2025. PyramidCharacter.point1 = location
  2026. PyramidCharacter.point2 = location
  2027. PyramidCharacter.point3 = location
  2028. PyramidCharacter.point4 = location
  2029. end
  2030. local stock_core = Instance.new("Part")
  2031. stock_core.Anchored = true
  2032. stock_core.BottomSurface = "Smooth"
  2033. stock_core.Color = Color3.new(1, 1, 1)
  2034. stock_core.FormFactor = "Custom"
  2035. stock_core.Locked = true
  2036. stock_core.Name = "CubePyramid"
  2037. stock_core.Size = Vector3.new(0.5, 0.5, 0.5)
  2038. stock_core.TopSurface = "Smooth"
  2039. PyramidCharacter.stock_core = stock_core
  2040. PyramidCharacter.core = stock_core:Clone()
  2041. PyramidCharacter.Archivable = false
  2042. PyramidCharacter.core_mesh = Instance.new("BlockMesh", core)
  2043. PyramidCharacter.core_lights = {}
  2044. PyramidCharacter.coreLightCount = 1
  2045. for index = 1, PyramidCharacter.coreLightCount do
  2046. PyramidCharacter.core_lights[index] = Instance.new("PointLight", core)
  2047. end
  2048. PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
  2049. PyramidCharacter.camera_position = Vector3.new()
  2050. Camera.Changed:connect(function(property)
  2051. if PyramidCharacter.visible then
  2052. if property == "CoordinateFrame" then
  2053. local cframe, focus = Camera.CoordinateFrame, Camera.Focus
  2054. local eventTime = time()
  2055. local connection
  2056. connection = Camera.Changed:connect(function()
  2057. connection:disconnect()
  2058. if eventTime == time() and Camera.Focus ~= focus then
  2059. local camera_distance = PyramidCharacter.camera_distance
  2060. Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  2061. PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  2062. end
  2063. end)
  2064. coroutine.yield()
  2065. if Camera.Focus == focus then
  2066. PyramidCharacter.camera_distance = (focus.p - cframe.p).magnitude
  2067. else
  2068. local camera_distance = PyramidCharacter.camera_distance
  2069. Camera.Focus = Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)
  2070. PyramidCharacter.camera_position = (Camera.CoordinateFrame * CFrame.new(0, 0, -camera_distance)).p
  2071. end
  2072. if connection.connected then
  2073. connection:disconnect()
  2074. end
  2075. end
  2076. end
  2077. end)
  2078. function PyramidCharacter.Animate()
  2079. local total_time = time()
  2080. local core = PyramidCharacter.core
  2081. local frame = PyramidCharacter.frame
  2082. if PyramidCharacter.visible then
  2083. local core_mesh = PyramidCharacter.core_mesh
  2084. local core_lights = PyramidCharacter.core_lights
  2085. if not frame or frame.Parent ~= core then
  2086. frame = Instance.new("Model")
  2087. frame.Archivable = false
  2088. frame.Parent = core
  2089. PyramidCharacter.frame = frame
  2090. end
  2091. if core.Parent ~= Workspace then
  2092. core = PyramidCharacter.stock_core:Clone()
  2093. PyramidCharacter.core = core
  2094. core.Archivable = false
  2095. core.Parent = Workspace
  2096. Network.TransmitServer("chatAdornee = ...", core)
  2097. end
  2098. if core_mesh.Parent ~= core then
  2099. core_mesh = Instance.new("BlockMesh", core)
  2100. PyramidCharacter.core_mesh = core_mesh
  2101. end
  2102. for index, core_light in ipairs(core_lights) do
  2103. if core_light.Parent ~= core then
  2104. core_light = Instance.new("PointLight", core)
  2105. core_lights[index] = core_light
  2106. end
  2107. local vertexColor = Vector3.new(Utility.GetRainbowRGB(total_time)) * 0.25 + Vector3.new(1, 1, 1) * 0.75
  2108. core_light.Color = Color3.new(vertexColor.X, vertexColor.Y, vertexColor.Z)
  2109. core_light.Brightness = 0.85 + 0.15 * math.random()
  2110. if core_light.Range ~= 30 then
  2111. core_light.Range = 30
  2112. end
  2113. if not core_light.Shadows then
  2114. core_light.Shadows = true
  2115. end
  2116. end
  2117. if core_mesh.Offset ~= Vector3.new(0, 0, 0) then
  2118. core_mesh.Offset = Vector3.new(0, 0, 0)
  2119. end
  2120. if not core.Anchored then
  2121. core.Anchored = true
  2122. end
  2123. if core.Transparency ~= 0 then
  2124. core.Transparency = 0
  2125. end
  2126. local core_mesh_scale = PyramidCharacter.core_mesh_scale
  2127. local transition_speed = (math.sin(total_time * math.tau) + 1) / 16
  2128. 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()
  2129.  
  2130. * 0.5 + 0.5) * transition_speed
  2131. core_mesh.Scale = core_mesh_scale * 2
  2132. local center = CFrame.new(PyramidCharacter.camera_position) * CFrame.Angles(0, total_time * math.tau, 0)
  2133. local cframe1 = CFrame.new(PyramidCharacter.head_radius, 0, 0)
  2134. local cframe2 = CFrame.Angles(math.tau / -3, 0, 0)
  2135. local cframe3 = CFrame.Angles(0, math.tau / 3, 0)
  2136. local cframe4 = center * cframe3
  2137. local desired1 = center * CFrame.new(0, PyramidCharacter.head_radius, 0)
  2138. local desired2 = center * cframe2 * cframe1
  2139. local desired3 = cframe4 * cframe2 * cframe1
  2140. local desired4 = cframe4 * cframe3 * cframe2 * cframe1
  2141. local point1 = (PyramidCharacter.point1 * 3 + desired1.p) / 4
  2142. local point2 = (PyramidCharacter.point2 * 3 + desired2.p) / 4
  2143. local point3 = (PyramidCharacter.point3 * 3 + desired3.p) / 4
  2144. local point4 = (PyramidCharacter.point4 * 3 + desired4.p) / 4
  2145. PyramidCharacter.point1 = point1
  2146. PyramidCharacter.point2 = point2
  2147. PyramidCharacter.point3 = point3
  2148. PyramidCharacter.point4 = point4
  2149. local head_properties = PyramidCharacter.head_properties
  2150. PyramidCharacter.CreateTriangle(point1, point2, point3, head_properties, frame, 1).Archivable = false
  2151. PyramidCharacter.CreateTriangle(point2, point3, point4, head_properties, frame, 2).Archivable = false
  2152. PyramidCharacter.CreateTriangle(point3, point4, point1, head_properties, frame, 3).Archivable = false
  2153. PyramidCharacter.CreateTriangle(point4, point1, point2, head_properties, frame, 4).Archivable = false
  2154. core.CFrame = CFrame.new((point1 + point2 + point3 + point4) / 4) * CFrame.Angles(total_time * math.tau, total_time * math.tau / 2,
  2155.  
  2156. total_time * math.tau / 3)
  2157. PyramidCharacter.center = center
  2158. else
  2159. if core.Parent then
  2160. core:Destroy()
  2161. end
  2162. if frame and frame.Parent then
  2163. frame:Destroy()
  2164. end
  2165. PyramidCharacter.frame = nil
  2166. end
  2167. end
  2168. function PyramidCharacter.MainLoop()
  2169. PyramidCharacter.Animate()
  2170. RunService.Stepped:wait()
  2171. end
  2172. TaskScheduler.Start(function()
  2173. while true do
  2174. PyramidCharacter.MainLoop()
  2175. end
  2176. end)
  2177. ]])
  2178. Module.Create("CharacterAppearance", [[
  2179. CharacterAppearance.defaultAppearanceId = 3
  2180. CharacterAppearance.stock = {}
  2181. function CharacterAppearance.Create(properties)
  2182. local id = properties.Id
  2183. local bodyColors = Instance.new("BodyColors")
  2184. bodyColors.HeadColor = properties.HeadColor
  2185. bodyColors.TorsoColor = properties.TorsoColor
  2186. bodyColors.RightArmColor = properties.RightArmColor
  2187. bodyColors.LeftArmColor = properties.LeftArmColor
  2188. bodyColors.RightLegColor = properties.RightLegColor
  2189. bodyColors.LeftLegColor = properties.LeftLegColor
  2190. local characterObjects = {bodyColors}
  2191. local headObjects = {}
  2192. local data = {
  2193. characterObjects = characterObjects,
  2194. headObjects = headObjects,
  2195. tshirt = properties.TShirt
  2196. }
  2197. for _, assetId in ipairs(properties.CharacterAssets) do
  2198. TaskScheduler.Start(CharacterAppearance.LoadAsset, characterObjects, assetId)
  2199. end
  2200. for _, assetId in ipairs(properties.HeadAssets) do
  2201. TaskScheduler.Start(CharacterAppearance.LoadAsset, headObjects, assetId)
  2202. end
  2203. CharacterAppearance.stock[id] = data
  2204. end
  2205. function CharacterAppearance.GetDefaultAppearance()
  2206. return CharacterAppearance.stock[CharacterAppearance.defaultAppearanceId]
  2207. end
  2208. function CharacterAppearance.LoadAsset(objects, assetId)
  2209. local asset = InsertService:LoadAsset(assetId)
  2210. for _, child in ipairs(asset:GetChildren()) do
  2211. child.Archivable = true
  2212. table.insert(objects, child:Clone())
  2213. end
  2214. end
  2215. CharacterAppearance.Create {
  2216. Id = 1,
  2217. HeadColor = BrickColor.new("Institutional white"),
  2218. TorsoColor = BrickColor.new("Institutional white"),
  2219. RightArmColor = BrickColor.new("Institutional white"),
  2220. LeftArmColor = BrickColor.new("Institutional white"),
  2221. RightLegColor = BrickColor.new("Institutional white"),
  2222. LeftLegColor = BrickColor.new("Institutional white"),
  2223. CharacterAssets = {
  2224. 90825058, 90825211,
  2225. 27112056, 27112052,
  2226. 27112039, 27112025,
  2227. 27112068, 38322996
  2228. },
  2229. HeadAssets = {
  2230. 20722130,
  2231. 8330576
  2232. }
  2233. }
  2234. CharacterAppearance.Create {
  2235. Id = 2,
  2236. HeadColor = BrickColor.new("Institutional white"),
  2237. TorsoColor = BrickColor.new("Institutional white"),
  2238. RightArmColor = BrickColor.new("Institutional white"),
  2239. LeftArmColor = BrickColor.new("Institutional white"),
  2240. RightLegColor = BrickColor.new("Institutional white"),
  2241. LeftLegColor = BrickColor.new("Institutional white"),
  2242. CharacterAssets = {
  2243. 90825058, 90825211,
  2244. 11748356, 1029025,
  2245. 1235488, 27112056,
  2246. 27112052, 27112039,
  2247. 27112025, 27112068
  2248. },
  2249. HeadAssets = {
  2250. 20722130
  2251. }
  2252. }
  2253. CharacterAppearance.Create {
  2254. Id = 3,
  2255. HeadColor = BrickColor.new("Pastel brown"),
  2256. TorsoColor = BrickColor.new("Pastel brown"),
  2257. RightArmColor = BrickColor.new("Pastel brown"),
  2258. LeftArmColor = BrickColor.new("Pastel brown"),
  2259. RightLegColor = BrickColor.new("White"),
  2260. LeftLegColor = BrickColor.new("White"),
  2261. CharacterAssets = {
  2262. 134289125, 48474356,
  2263. 100339040, 46302558,
  2264. 153955895
  2265. },
  2266. HeadAssets = {},
  2267. TShirt = "rbxassetid://148856353"
  2268. }
  2269. ]])
  2270. Module.Create("PlayerControl", [[
  2271. PlayerControl.fly_acceleration = 10
  2272. PlayerControl.fly_basespeed = 250
  2273. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  2274. PlayerControl.featherfallEnabled = true
  2275. PlayerControl.pushable = false
  2276. PlayerControl.rolling = false
  2277. PlayerControl.rollingAngle = 0
  2278. PlayerControl.rollingOffset = 0
  2279. PlayerControl.rollingMaxOffset = 3
  2280. PlayerControl.rollingSpeed = 1 / 50
  2281. PlayerControl.characterEnabled = false
  2282. PlayerControl.characterMode = "normal"
  2283. local character = nil
  2284. local flying, flyingMomentum, flyingTilt = false, Vector3.new(), 0
  2285. local pose, regeneratingHealth, jumpDebounce = "Standing", false, false
  2286. -- TODO: make local variables public
  2287. local model, bodyColors, leftArmMesh, leftLegMesh, rightArmMesh, rightLegMesh, torsoMesh, wildcardHat, wildcardHandle, wildcardMesh, pants, shirt, humanoid,
  2288.  
  2289. head, leftArm, leftLeg, rightArm, rightLeg, torso, rootPart, rootJoint, face, soundFreeFalling, soundGettingUp, soundRunning, leftHip, leftShoulder,
  2290.  
  2291. rightHip, rightShoulder, neck, wildcardWeld, feetPart, feetWeld, feetTouchInterest, bodyGyro, bodyVelocity, headMesh, torsoLight
  2292. local AnimateCharacter
  2293. local chatBubbles = {}
  2294. local chatCharacterLimit = 240
  2295. function PlayerControl.Chat(message)
  2296. Network.TransmitServer(string.format("ChatBubble.Create(%q)", tostring(message)))
  2297. end
  2298. function PlayerControl.CreateCharacter()
  2299. local characterMode = PlayerControl.characterMode
  2300. if characterMode == "normal" then
  2301. if not PlayerControl.characterEnabled then
  2302. return
  2303. end
  2304. local appearance = CharacterAppearance.GetDefaultAppearance()
  2305. local active = true
  2306. local torsoCFrame = (torso and torso.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2307. if torsoCFrame.p.Y < -450 then
  2308. torsoCFrame = CFrame.new(0, 10, 0)
  2309. end
  2310. local rootPartCFrame = (rootPart and rootPart.CFrame) or PlayerControl.torso_cframe or CFrame.new(0, 10, 0)
  2311. if rootPartCFrame.p.Y < -450 then
  2312. rootPartCFrame = CFrame.new(0, 10, 0)
  2313. end
  2314. local cameraCFrame = Camera.CoordinateFrame
  2315. local connections = {}
  2316. local feetTouching = {}
  2317. local previousWalkSpeed = 0
  2318. local prevLeftHip, prevLeftShoulder, prevRightHip, prevRightShoulder = leftHip, leftShoulder, rightHip, rightShoulder
  2319. model = Instance.new("Model")
  2320. humanoid = Instance.new("Humanoid", model)
  2321. head = Instance.new("Part", model)
  2322. leftArm = Instance.new("Part", model)
  2323. leftLeg = Instance.new("Part", model)
  2324. rightArm = Instance.new("Part", model)
  2325. rightLeg = Instance.new("Part", model)
  2326. torso = Instance.new("Part", model)
  2327. rootPart = Instance.new("Part", model)
  2328. soundFallingDown = Instance.new("Sound", head)
  2329. soundFreeFalling = Instance.new("Sound", head)
  2330. soundGettingUp = Instance.new("Sound", head)
  2331. soundJumping = Instance.new("Sound", head)
  2332. soundRunning = Instance.new("Sound", head)
  2333. leftHip = Instance.new("Motor", torso)
  2334. leftShoulder = Instance.new("Motor", torso)
  2335. rightHip = Instance.new("Motor", torso)
  2336. rightShoulder = Instance.new("Motor", torso)
  2337. neck = Instance.new("Motor", torso)
  2338. rootJoint = Instance.new("Motor", rootPart)
  2339. feetPart = Instance.new("Part", model)
  2340. feetWeld = Instance.new("Weld", torso)
  2341. bodyGyro = Instance.new("BodyGyro", rootPart)
  2342. bodyVelocity = Instance.new("BodyVelocity", rootPart)
  2343. model.Archivable = false
  2344. model.Name = UserInterface.player_name
  2345. model.PrimaryPart = head
  2346. humanoid.LeftLeg = leftLeg
  2347. humanoid.RightLeg = rightLeg
  2348. humanoid.Torso = rootPart
  2349. head.CFrame = torsoCFrame * CFrame.new(0, 1.5, 0)
  2350. head.FormFactor = "Symmetric"
  2351. head.Locked = true
  2352. head.Name = "Head"
  2353. head.Size = Vector3.new(2, 1, 1)
  2354. head.TopSurface = "Smooth"
  2355. leftArm.CanCollide = false
  2356. leftArm.CFrame = torsoCFrame * CFrame.new(-1.5, 0, 0)
  2357. leftArm.FormFactor = "Symmetric"
  2358. leftArm.Locked = true
  2359. leftArm.Name = "Left Arm"
  2360. leftArm.Size = Vector3.new(1, 2, 1)
  2361. leftLeg.BottomSurface = "Smooth"
  2362. leftLeg.CanCollide = false
  2363. leftLeg.CFrame = torsoCFrame * CFrame.new(-0.5, -2, 0)
  2364. leftLeg.FormFactor = "Symmetric"
  2365. leftLeg.Locked = true
  2366. leftLeg.Name = "Left Leg"
  2367. leftLeg.Size = Vector3.new(1, 2, 1)
  2368. leftLeg.TopSurface = "Smooth"
  2369. rightArm.CanCollide = false
  2370. rightArm.CFrame = torsoCFrame * CFrame.new(1.5, 0, 0)
  2371. rightArm.FormFactor = "Symmetric"
  2372. rightArm.Locked = true
  2373. rightArm.Name = "Right Arm"
  2374. rightArm.Size = Vector3.new(1, 2, 1)
  2375. rightLeg.BottomSurface = "Smooth"
  2376. rightLeg.CanCollide = false
  2377. rightLeg.CFrame = torsoCFrame * CFrame.new(0.5, -2, 0)
  2378. rightLeg.FormFactor = "Symmetric"
  2379. rightLeg.Locked = true
  2380. rightLeg.Name = "Right Leg"
  2381. rightLeg.Size = Vector3.new(1, 2, 1)
  2382. rightLeg.TopSurface = "Smooth"
  2383. torso.CFrame = torsoCFrame
  2384. torso.FormFactor = "Symmetric"
  2385. torso.LeftSurface = "Weld"
  2386. torso.Locked = true
  2387. torso.RightSurface = "Weld"
  2388. torso.Name = "Torso"
  2389. torso.Size = Vector3.new(2, 2, 1)
  2390. rootPart.BottomSurface = "Smooth"
  2391. rootPart.BrickColor = BrickColor.Blue()
  2392. rootPart.CFrame = rootPartCFrame
  2393. rootPart.FormFactor = "Symmetric"
  2394. rootPart.LeftSurface = "Weld"
  2395. rootPart.Locked = true
  2396. rootPart.RightSurface = "Weld"
  2397. rootPart.Name = "HumanoidRootPart"
  2398. rootPart.Size = Vector3.new(2, 2, 1)
  2399. rootPart.TopSurface = "Smooth"
  2400. rootPart.Transparency = 1
  2401. soundFreeFalling.Archivable = false
  2402. soundFreeFalling.SoundId = "rbxasset://sounds/swoosh.wav"
  2403. soundGettingUp.Archivable = false
  2404. soundGettingUp.SoundId = "rbxasset://sounds/hit.wav"
  2405. soundRunning.Archivable = false
  2406. soundRunning.SoundId = "rbxasset://sounds/bfsl-minifigfoots1.mp3"
  2407. soundRunning.Looped = true
  2408. leftHip.C0 = CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2409. leftHip.C1 = CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2410. leftHip.MaxVelocity = 0.1
  2411. leftHip.Name = "Left Hip"
  2412. leftHip.Part0 = torso
  2413. leftHip.Part1 = leftLeg
  2414. leftShoulder.C0 = CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2415. leftShoulder.C1 = CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0)
  2416. leftShoulder.MaxVelocity = 0.15
  2417. leftShoulder.Name = "Left Shoulder"
  2418. leftShoulder.Part0 = torso
  2419. leftShoulder.Part1 = leftArm
  2420. rightHip.C0 = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2421. rightHip.C1 = CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2422. rightHip.MaxVelocity = 0.1
  2423. rightHip.Name = "Right Hip"
  2424. rightHip.Part0 = torso
  2425. rightHip.Part1 = rightLeg
  2426. rightShoulder.C0 = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2427. rightShoulder.C1 = CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0)
  2428. rightShoulder.MaxVelocity = 0.15
  2429. rightShoulder.Name = "Right Shoulder"
  2430. rightShoulder.Part0 = torso
  2431. rightShoulder.Part1 = rightArm
  2432. if prevLeftHip then
  2433. leftHip.CurrentAngle = prevLeftHip.CurrentAngle
  2434. leftHip.DesiredAngle = prevLeftHip.DesiredAngle
  2435. end
  2436. if prevLeftShoulder then
  2437. leftShoulder.CurrentAngle = prevLeftShoulder.CurrentAngle
  2438. leftShoulder.DesiredAngle = prevLeftShoulder.DesiredAngle
  2439. end
  2440. if prevRightHip then
  2441. rightHip.CurrentAngle = prevRightHip.CurrentAngle
  2442. rightHip.DesiredAngle = prevRightHip.DesiredAngle
  2443. end
  2444. if prevRightShoulder then
  2445. rightShoulder.CurrentAngle = prevRightShoulder.CurrentAngle
  2446. rightShoulder.DesiredAngle = prevRightShoulder.DesiredAngle
  2447. end
  2448. neck.C0 = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2449. neck.C1 = CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  2450. neck.Name = "Neck"
  2451. neck.Part0 = torso
  2452. neck.Part1 = head
  2453. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2454. rootJoint.C1 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2455. rootJoint.Name = "RootJoint"
  2456. rootJoint.Part0 = rootPart
  2457. rootJoint.Part1 = torso
  2458. feetPart.BottomSurface = "Smooth"
  2459. feetPart.CanCollide = false
  2460. feetPart.CFrame = torsoCFrame * CFrame.new(0, -3.1, 0)
  2461. feetPart.FormFactor = "Custom"
  2462. feetPart.Locked = true
  2463. feetPart.Name = "Platform"
  2464. feetPart.Size = Vector3.new(1.8, 0.2, 0.8)
  2465. feetPart.TopSurface = "Smooth"
  2466. feetPart.Transparency = 1
  2467. feetWeld.C0 = CFrame.new(0, -3, 0)
  2468. feetWeld.C1 = CFrame.new(0, 0.1, 0)
  2469. feetWeld.Name = "PlatformWeld"
  2470. feetWeld.Part0 = torso
  2471. feetWeld.Part1 = feetPart
  2472. table.insert(connections, feetPart.Touched:connect(function(hit)
  2473. feetTouching[hit] = true
  2474. end))
  2475. table.insert(connections, feetPart.TouchEnded:connect(function(hit)
  2476. feetTouching[hit] = nil
  2477. end))
  2478. feetTouchInterest = feetPart:FindFirstChild("TouchInterest")
  2479. bodyGyro.D = 3250
  2480. bodyGyro.P = 400000
  2481. bodyGyro.maxTorque = Vector3.new(1000000000, 0, 1000000000)
  2482. bodyVelocity.P = 5000
  2483. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  2484. bodyVelocity.velocity = Vector3.new(0, 0, 0)
  2485. torsoLight = Instance.new("PointLight", torso)
  2486. torsoLight.Brightness = 0.4
  2487. torsoLight.Color = Color3.new(1, 1, 1)
  2488. torsoLight.Range = 16
  2489. torsoLight.Shadows = true
  2490. local ff1, ff2, ff3, ff4, ff5, ff6, ff7, ff8, ff9 = Instance.new("ForceField", head), Instance.new("ForceField", leftArm), Instance.new
  2491.  
  2492. ("ForceField", leftLeg), Instance.new("ForceField", rightArm), Instance.new("ForceField", rightLeg), Instance.new("ForceField", torso), Instance.new
  2493.  
  2494. ("ForceField", wildcardHandle), Instance.new("ForceField", feetPart), Instance.new("ForceField", rootPart)
  2495. local forcefields = {[ff1] = head, [ff2] = leftArm, [ff3] = leftLeg, [ff4] = rightArm, [ff5] = rightLeg, [ff6] = torso, [ff7] =
  2496.  
  2497. wildcardHandle, [ff8] = feetPart, [ff9] = rootPart}
  2498. local objects = {[humanoid] = true, [head] = true, [leftArm] = true, [leftLeg] = true, [rightArm] = true, [rightLeg] = true, [torso] = true,
  2499.  
  2500. [rootPart] = true, [rootJoint] = true, [soundFreeFalling] = true, [soundGettingUp] = true, [soundRunning] = true, [leftHip] = true, [leftShoulder] = true,
  2501.  
  2502. [rightHip] = true, [rightShoulder] = true, [neck] = true, [feetPart] = true, [feetWeld] = true, [feetTouchInterest] = true, [bodyGyro] = true,
  2503.  
  2504. [bodyVelocity] = true, [ff1] = true, [ff2] = true, [ff3] = true, [ff4] = true, [ff5] = true, [ff6] = true, [ff7] = true, [ff8] = true, [ff9] = true}
  2505. local tshirtUrl = appearance.tshirt
  2506. if tshirtUrl then
  2507. local tshirt = Instance.new("Decal", torso)
  2508. tshirt.Name = "roblox"
  2509. tshirt.Texture = tshirtUrl
  2510. objects[tshirt] = true
  2511. end
  2512. for _, template in ipairs(appearance.characterObjects) do
  2513. local object = template:Clone()
  2514. local newObjects = {object}
  2515. for _, object in ipairs(newObjects) do
  2516. objects[object] = true
  2517. for _, child in ipairs(object:GetChildren()) do
  2518. table.insert(newObjects, child)
  2519. end
  2520. end
  2521. if object:IsA("BodyColors") then
  2522. head.BrickColor = object.HeadColor
  2523. leftArm.BrickColor = object.LeftArmColor
  2524. leftLeg.BrickColor = object.LeftLegColor
  2525. rightArm.BrickColor = object.RightArmColor
  2526. rightLeg.BrickColor = object.RightLegColor
  2527. torso.BrickColor = object.TorsoColor
  2528. elseif object:IsA("Hat") then
  2529. local handle = object:FindFirstChild("Handle")
  2530. if handle and handle:IsA("BasePart") then
  2531. local weld = Instance.new("Weld", head)
  2532. weld.C0 = CFrame.new(0, 0.5, 0)
  2533. local attachmentPos = object.AttachmentPos
  2534. local attachmentRight = object.AttachmentRight
  2535. local attachmentUp = object.AttachmentUp
  2536. local attachmentForward = object.AttachmentForward
  2537. weld.C1 = CFrame.new(attachmentPos.X, attachmentPos.Y, attachmentPos.Z,
  2538. attachmentRight.X, attachmentUp.X, -attachmentForward.X,
  2539. attachmentRight.Y, attachmentUp.Y, -attachmentForward.Y,
  2540. attachmentRight.Z, attachmentUp.Z, -attachmentForward.Z)
  2541. weld.Name = "HeadWeld"
  2542. weld.Part0 = head
  2543. weld.Part1 = handle
  2544. handle.Parent = model
  2545. local antiGravity = Instance.new("BodyForce", handle)
  2546. antiGravity.force = Vector3.new(0, handle:GetMass() * 196.2, 0)
  2547. objects[object] = false
  2548. object.Parent = nil
  2549. objects[weld] = true
  2550. end
  2551. end
  2552. object.Parent = model
  2553. end
  2554. local facePresent = false
  2555. local headMeshPresent = false
  2556. for _, template in ipairs(appearance.headObjects) do
  2557. local object = template:Clone()
  2558. local newObjects = {object}
  2559. for _, object in ipairs(newObjects) do
  2560. objects[object] = true
  2561. for _, child in ipairs(object:GetChildren()) do
  2562. table.insert(newObjects, child)
  2563. end
  2564. end
  2565. if object:IsA("DataModelMesh") then
  2566. headMeshPresent = true
  2567. elseif object:IsA("Decal") then
  2568. facePresent = true
  2569. end
  2570. object.Parent = head
  2571. end
  2572. if not facePresent then
  2573. local face = Instance.new("Decal", head)
  2574. face.Texture = "rbxasset://textures/face.png"
  2575. objects[face] = true
  2576. end
  2577. if not headMeshPresent then
  2578. local headMesh = Instance.new("SpecialMesh", head)
  2579. headMesh.Scale = Vector3.new(1.25, 1.25, 1.25)
  2580. objects[headMesh] = true
  2581. end
  2582. table.insert(connections, model.DescendantAdded:connect(function(object)
  2583. local success, is_localscript = pcall(Game.IsA, object, "LocalScript")
  2584. if success and is_localscript then
  2585. pcall(Utility.SetProperty, object, "Disabled", true)
  2586. local changed_connection = pcall(object.Changed.connect, object.Changed, function(property)
  2587. if property == "Disabled" and not object.Disabled then
  2588. pcall(Utility.SetProperty, object, "Disabled", true)
  2589. Network.TransmitServer("(...):Destroy()", object)
  2590. end
  2591. end)
  2592. end
  2593. if not objects[object] then
  2594. Network.TransmitServer("(...):Destroy()", object)
  2595. end
  2596. end))
  2597. model.Parent = Workspace
  2598. Player.Character = model
  2599. Camera.CameraSubject = humanoid
  2600. Camera.CameraType = "Track"
  2601. Camera.CoordinateFrame = cameraCFrame
  2602. local IsStanding
  2603. local RegenerateHealth
  2604. local ResetCharacter
  2605. function IsStanding()
  2606. return not not next(feetTouching)
  2607. end
  2608. function RegenerateHealth()
  2609. if humanoid.Health < 1 then
  2610. humanoid.Health = 100
  2611. elseif not regeneratingHealth then
  2612. regeneratingHealth = true
  2613. local elapsedTime = wait(1)
  2614. regeneratingHealth = false
  2615. if humanoid.Health < 100 then
  2616. humanoid.Health = math.min(humanoid.Health + elapsedTime, 100)
  2617. end
  2618. end
  2619. end
  2620. function ResetCharacter()
  2621. for index, connection in ipairs(connections) do
  2622. connection:disconnect()
  2623. end
  2624. active = false
  2625. end
  2626. table.insert(connections, model.AncestryChanged:connect(ResetCharacter))
  2627. table.insert(connections, model.DescendantRemoving:connect(function(object)
  2628. local parent = forcefields[object]
  2629. if parent then
  2630. forcefields[object] = nil
  2631. local new_forcefield = Instance.new("ForceField")
  2632. forcefields[new_forcefield] = parent
  2633. objects[new_forcefield] = true
  2634. new_forcefield.Parent = parent
  2635. elseif objects[object] then
  2636. ResetCharacter()
  2637. end
  2638. end))
  2639. table.insert(connections, humanoid.HealthChanged:connect(RegenerateHealth))
  2640. table.insert(connections, humanoid.Climbing:connect(function() pose = "Climbing" end))
  2641. table.insert(connections, humanoid.FallingDown:connect(function(state) pose = "FallingDown" end))
  2642. table.insert(connections, humanoid.FreeFalling:connect(function(state) pose = "FreeFall" if state then soundFreeFalling:Play() else
  2643.  
  2644. soundFreeFalling:Pause() end end))
  2645. table.insert(connections, humanoid.GettingUp:connect(function(state) pose = "GettingUp" if state then soundGettingUp:Play() else
  2646.  
  2647. soundGettingUp:Pause() end end))
  2648. table.insert(connections, humanoid.PlatformStanding:connect(function() pose = "PlatformStanding" end))
  2649. table.insert(connections, humanoid.Seated:connect(function() pose = "Seated" end))
  2650. table.insert(connections, humanoid.Swimming:connect(function(speed) if speed > 0 then pose = "Swimming" else pose = "Standing" end end))
  2651. local previousRootPartCFrame = rootPart.CFrame
  2652. TaskScheduler.Start(function()
  2653. while active do
  2654. local totalTime = TaskScheduler.GetCurrentTime()
  2655. local stepTime = 1 / 60
  2656. if not PlayerControl.characterEnabled then
  2657. ResetCharacter()
  2658. break
  2659. end
  2660. torsoLight.Brightness = 0.5 + 0.15 * math.sin(totalTime * 0.75 * math.pi)
  2661. local featherfallEnabled = PlayerControl.IsFeatherfallEnabled()
  2662. local rootPartCFrame = rootPart.CFrame
  2663. if not jumpDebounce and UserInterface.IsKeyDown(" ") then
  2664. if humanoid.Sit then
  2665. humanoid.Sit = false
  2666. end
  2667. if IsStanding() then
  2668. jumpDebounce = true
  2669. pose = "Jumping"
  2670. rootPart.Velocity = Vector3.new(rootPart.Velocity.X, 50, rootPart.Velocity.Z)
  2671. torso.Velocity = Vector3.new(torso.Velocity.X, 50, torso.Velocity.Z)
  2672. TaskScheduler.Schedule(1, function()
  2673. if pose == "Jumping" then
  2674. pose = "FreeFall"
  2675. end
  2676. jumpDebounce = false
  2677. humanoid.Jump = false
  2678. end)
  2679. end
  2680. end
  2681. local cameraCFrame = Camera.CoordinateFrame
  2682. local cameraDirection = cameraCFrame.lookVector
  2683. if flying then
  2684. if PlayerControl.rolling then
  2685. local rootPartCFrame = rootPart.CFrame
  2686. local speed = (rootPartCFrame - rootPartCFrame.p):pointToObjectSpace(rootPart.Velocity).Y
  2687. local decay = 0.5 ^ stepTime
  2688. if math.abs(speed) <= 50 then
  2689. PlayerControl.rollingAngle = (((PlayerControl.rollingAngle + 0.5) % 1 - 0.5) * decay) % 1
  2690. PlayerControl.rollingOffset = PlayerControl.rollingOffset * decay
  2691. else
  2692. PlayerControl.rollingAngle = (PlayerControl.rollingAngle + stepTime * speed *
  2693.  
  2694. PlayerControl.rollingSpeed) % 1
  2695. PlayerControl.rollingOffset = (PlayerControl.rollingOffset + PlayerControl.rollingMaxOffset * (1 /
  2696.  
  2697. decay - 1)) * decay
  2698. end
  2699. rootJoint.C0 = (CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0) * CFrame.Angles(PlayerControl.rollingAngle *
  2700.  
  2701. 2 * math.pi, 0, 0)) * CFrame.new(0, -PlayerControl.rollingOffset, 0)
  2702. else
  2703. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2704. PlayerControl.rollingAngle = 0
  2705. PlayerControl.rollingOffset = 0
  2706. end
  2707. rightShoulder.MaxVelocity = 0.5
  2708. leftShoulder.MaxVelocity = 0.5
  2709. rightShoulder.DesiredAngle = 0
  2710. leftShoulder.DesiredAngle = 0
  2711. rightHip.DesiredAngle = 0
  2712. leftHip.DesiredAngle = 0
  2713. bodyGyro.D = 500
  2714. bodyGyro.P = 1e6
  2715. bodyGyro.maxTorque = Vector3.new(1e6, 1e6, 1e6)
  2716. bodyVelocity.P = 1250
  2717. bodyVelocity.maxForce = Vector3.new(1e6, 1e6, 1e6)
  2718. local movementRight = 0
  2719. local movementForward = 0
  2720. local movementUp = 0
  2721. if UserInterface.IsKeyDown("a") and not UserInterface.IsKeyDown("d") then
  2722. movementRight = -1
  2723. elseif UserInterface.IsKeyDown("d") then
  2724. movementRight = 1
  2725. end
  2726. if UserInterface.IsKeyDown("w") then
  2727. movementUp = 0.2
  2728. if not UserInterface.IsKeyDown("s") then
  2729. movementForward = -1
  2730. end
  2731. elseif UserInterface.IsKeyDown("s") then
  2732. movementForward = 1
  2733. end
  2734. local movement = PlayerControl.fly_acceleration * cameraCFrame:vectorToWorldSpace(Vector3.new(movementRight,
  2735.  
  2736. movmentUp, movementForward))
  2737. local previousMomentum = flyingMomentum
  2738. local previousTilt = flyingTilt
  2739. flyingMomentum = movement + flyingMomentum * (1 - PlayerControl.fly_acceleration / PlayerControl.fly_speed)
  2740. flyingTilt = ((flyingMomentum * Vector3.new(1, 0, 1)).unit:Cross((previousMomentum * Vector3.new(1, 0, 1)).unit)).Y
  2741. if flyingTilt ~= flyingTilt or flyingTilt == math.huge then
  2742. flyingTilt = 0
  2743. end
  2744. local absoluteTilt = math.abs(flyingTilt)
  2745. if absoluteTilt > 0.06 or absoluteTilt < 0.0001 then
  2746. if math.abs(previousTilt) > 0.0001 then
  2747. flyingTilt = previousTilt * 0.9
  2748. else
  2749. flyingTilt = 0
  2750. end
  2751. else
  2752. flyingTilt = previousTilt * 0.77 + flyingTilt * 0.25
  2753. end
  2754. previousTilt = flyingTilt
  2755. if flyingMomentum.magnitude < 0.1 then
  2756. flyingMomentum = Vector3.new(0, 0, 0)
  2757. -- bodyGyro.cframe = cameraCFrame
  2758. else
  2759. local momentumOrientation = CFrame.new(Vector3.new(0, 0, 0), flyingMomentum)
  2760. local tiltOrientation = CFrame.Angles(0, 0, -20 * flyingTilt)
  2761. bodyGyro.cframe = momentumOrientation * tiltOrientation * CFrame.Angles(-0.5 * math.pi * math.min
  2762.  
  2763. (flyingMomentum.magnitude / PlayerControl.fly_speed, 1), 0, 0)
  2764. end
  2765. bodyVelocity.velocity = flyingMomentum + Vector3.new(0, 0.15695775618683547, 0)
  2766. rootPart.Velocity = flyingMomentum
  2767. previousMomentum = flyingMomentum
  2768. else
  2769. rootJoint.C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, 0)
  2770. PlayerControl.rollingAngle = 0
  2771. PlayerControl.rollingOffset = 0
  2772. bodyGyro.D = 3250
  2773. bodyGyro.P = 400000
  2774. bodyVelocity.P = 5000
  2775. local cameraDirection = cameraCFrame.lookVector
  2776. local walkDirection = Vector3.new(0, 0, 0)
  2777. local walkSpeed = 16
  2778. if UserInterface.IsKeyDown("w") or UserInterface.IsKeyDown("\17") then
  2779. if UserInterface.IsKeyDown("a") then
  2780. walkDirection = Vector3.new(cameraDirection.X + cameraDirection.Z, 0, cameraDirection.Z -
  2781.  
  2782. cameraDirection.X).unit
  2783. elseif UserInterface.IsKeyDown("d") then
  2784. walkDirection = Vector3.new(cameraDirection.X - cameraDirection.Z, 0, cameraDirection.Z +
  2785.  
  2786. cameraDirection.X).unit
  2787. else
  2788. walkDirection = Vector3.new(cameraDirection.X, 0, cameraDirection.Z).unit
  2789. end
  2790. elseif UserInterface.IsKeyDown("s") or UserInterface.IsKeyDown("\18") then
  2791. if UserInterface.IsKeyDown("a") then
  2792. walkDirection = Vector3.new(-cameraDirection.X + cameraDirection.Z, 0, -cameraDirection.Z -
  2793.  
  2794. cameraDirection.X).unit
  2795. elseif UserInterface.IsKeyDown("d") then
  2796. walkDirection = Vector3.new(-cameraDirection.X - cameraDirection.Z, 0, -cameraDirection.Z +
  2797.  
  2798. cameraDirection.X).unit
  2799. else
  2800. walkDirection = Vector3.new(-cameraDirection.X, 0, -cameraDirection.Z).unit
  2801. end
  2802. elseif UserInterface.IsKeyDown("a") then
  2803. walkDirection = Vector3.new(cameraDirection.Z, 0, -cameraDirection.X).unit
  2804. elseif UserInterface.IsKeyDown("d") then
  2805. walkDirection = Vector3.new(-cameraDirection.Z, 0, cameraDirection.X).unit
  2806. else
  2807. walkSpeed = 0
  2808. end
  2809. if walkSpeed ~= previousWalkSpeed then
  2810. if walkSpeed > 0 then
  2811. soundRunning:Play()
  2812. else
  2813. soundRunning:Pause()
  2814. end
  2815. end
  2816. if walkSpeed > 0 then
  2817. if pose ~= "Jumping" then
  2818. if IsStanding() then
  2819. pose = "Running"
  2820. else
  2821. pose = "FreeFall"
  2822. end
  2823. end
  2824. bodyGyro.cframe = CFrame.new(Vector3.new(), walkDirection)
  2825. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000)
  2826. bodyVelocity.maxForce = Vector3.new(1000000, maxForceY, 1000000)
  2827. else
  2828. if pose ~= "Jumping" then
  2829. if IsStanding() then
  2830. pose = "Standing"
  2831. else
  2832. pose = "FreeFall"
  2833. end
  2834. end
  2835. -- TODO: find and fix bug that causes torso to rotate back to some angle
  2836. bodyGyro.maxTorque = Vector3.new(1000000000, 1000000000, 1000000000) -- Vector3.new(1000000000, 0,
  2837.  
  2838. 1000000000)
  2839. if PlayerControl.pushable then
  2840. bodyVelocity.maxForce = Vector3.new(0, 0, 0)
  2841. else
  2842. bodyVelocity.maxForce = Vector3.new(1000000, 0, 1000000)
  2843. end
  2844. end
  2845. if featherfallEnabled then
  2846. local velocity = rootPart.Velocity
  2847. if velocity.Y > 50 then
  2848. rootPart.Velocity = Vector3.new(velocity.X, 50, velocity.Z)
  2849. elseif velocity.Y < -50 then
  2850. rootPart.Velocity = Vector3.new(velocity.X, -50, velocity.Z)
  2851. end
  2852. local distanceVector = rootPartCFrame.p - previousRootPartCFrame.p
  2853. local offsetX, offsetY, offsetZ = distanceVector.X, distanceVector.Y, distanceVector.Z
  2854. local MAX_MOVEMENT = 50 * 0.03333333507180214
  2855. if offsetX > MAX_MOVEMENT then
  2856. offsetX = MAX_MOVEMENT
  2857. elseif offsetX < -MAX_MOVEMENT then
  2858. offsetX = -MAX_MOVEMENT
  2859. end
  2860. if offsetY > MAX_MOVEMENT then
  2861. offsetY = MAX_MOVEMENT
  2862. elseif offsetY < -MAX_MOVEMENT then
  2863. offsetY = -MAX_MOVEMENT
  2864. end
  2865. if offsetZ > MAX_MOVEMENT then
  2866. offsetZ = MAX_MOVEMENT
  2867. elseif offsetZ < -MAX_MOVEMENT then
  2868. offsetZ = -MAX_MOVEMENT
  2869. end
  2870. local offset = Vector3.new(offsetX, offsetY, offsetZ)
  2871. if offset ~= distanceVector then
  2872. rootPartCFrame = previousRootPartCFrame + offset
  2873. --rootPart.CFrame = rootPartCFrame
  2874. end
  2875. end
  2876. local walkingVelocity = walkDirection * walkSpeed
  2877. bodyVelocity.velocity = walkingVelocity
  2878. if not jumpDebounce and math.abs(rootPart.Velocity.Y) <= 0.1 then
  2879. rootPart.Velocity = Vector3.new(walkingVelocity.X, rootPart.Velocity.Y, walkingVelocity.Z)
  2880. end
  2881. previousWalkSpeed = walkSpeed
  2882. if pose == "Jumping" or jumpDebounce then
  2883. rightShoulder.MaxVelocity = 0.5
  2884. leftShoulder.MaxVelocity = 0.5
  2885. rightShoulder.DesiredAngle = 3.14
  2886. leftShoulder.DesiredAngle = -3.14
  2887. rightHip.DesiredAngle = 0
  2888. leftHip.DesiredAngle = 0
  2889. elseif pose == "FreeFall" then
  2890. rightShoulder.MaxVelocity = 0.5
  2891. leftShoulder.MaxVelocity = 0.5
  2892. rightShoulder.DesiredAngle = 3.14
  2893. leftShoulder.DesiredAngle = -3.14
  2894. rightHip.DesiredAngle = 0
  2895. leftHip.DesiredAngle = 0
  2896. elseif pose == "Seated" then
  2897. rightShoulder.MaxVelocity = 0.15
  2898. leftShoulder.MaxVelocity = 0.15
  2899. rightShoulder.DesiredAngle = 3.14 / 2
  2900. leftShoulder.DesiredAngle = -3.14 / 2
  2901. rightHip.DesiredAngle = 3.14 / 2
  2902. leftHip.DesiredAngle = -3.14 / 2
  2903. else
  2904. local climbFudge = 0
  2905. local amplitude
  2906. local frequency
  2907. if pose == "Running" then
  2908. rightShoulder.MaxVelocity = 0.15
  2909. leftShoulder.MaxVelocity = 0.15
  2910. amplitude = 1
  2911. frequency = 9
  2912. elseif (pose == "Climbing") then
  2913. rightShoulder.MaxVelocity = 0.5
  2914. leftShoulder.MaxVelocity = 0.5
  2915. amplitude = 1
  2916. frequency = 9
  2917. climbFudge = 3.14
  2918. else
  2919. amplitude = 0.1
  2920. frequency = 1
  2921. end
  2922. local desiredAngle = amplitude * math.sin(totalTime * frequency)
  2923. rightShoulder.DesiredAngle = desiredAngle + climbFudge
  2924. leftShoulder.DesiredAngle = desiredAngle - climbFudge
  2925. rightHip.DesiredAngle = -desiredAngle
  2926. leftHip.DesiredAngle = -desiredAngle
  2927. end
  2928. end
  2929. previousRootPartCFrame = rootPartCFrame
  2930. RunService.RenderStepped:wait()
  2931. end
  2932. if model.Parent ~= nil then
  2933. model.Parent = nil
  2934. end
  2935. PlayerControl.CreateCharacter()
  2936. end)
  2937. humanoid.Health = 100
  2938. character = model
  2939. Network.TransmitServer("chatAdornee = ...", head)
  2940. elseif characterMode == "pyramid" then
  2941. if PlayerControl.characterEnabled then
  2942. Camera.CameraType = "Fixed"
  2943. PyramidCharacter.camera_distance = (Camera.Focus.p - Camera.CoordinateFrame.p).magnitude
  2944. PyramidCharacter.camera_position = Camera.Focus.p
  2945. PyramidCharacter.Teleport(Camera.Focus.p)
  2946. PyramidCharacter.visible = true
  2947. Player.Character = nil
  2948. else
  2949. PyramidCharacter.visible = false
  2950. end
  2951. end
  2952. end
  2953. function PlayerControl.GetCharacter()
  2954. return character
  2955. end
  2956. function PlayerControl.GetHead()
  2957. local characterMode = PlayerControl.characterMode
  2958. if characterMode == "normal" then
  2959. return head
  2960. elseif characterMode == "pyramid" then
  2961. return PyramidCharacter.core
  2962. end
  2963. end
  2964. function PlayerControl.GetHumanoid()
  2965. return humanoid
  2966. end
  2967. function PlayerControl.GetRootPart()
  2968. return rootPart
  2969. end
  2970. function PlayerControl.GetTorso()
  2971. return torso
  2972. end
  2973. function PlayerControl.IsEnabled()
  2974. return PlayerControl.characterEnabled
  2975. end
  2976. function PlayerControl.IsFeatherfallEnabled()
  2977. return PlayerControl.featherfallEnabled
  2978. end
  2979. function PlayerControl.IsPushable()
  2980. return PlayerControl.pushable
  2981. end
  2982. function PlayerControl.IsRolling()
  2983. return PlayerControl.rolling
  2984. end
  2985. function PlayerControl.ResetCharacter()
  2986. if character and character.Parent then
  2987. character.Parent = nil
  2988. end
  2989. PyramidCharacter.visible = false
  2990. end
  2991. function PlayerControl.SetEnabled(state, no_animation)
  2992. state = not not state
  2993. if state ~= PlayerControl.characterEnabled then
  2994. PlayerControl.characterEnabled = state
  2995. local characterMode = PlayerControl.characterMode
  2996. if characterMode == "normal" then
  2997. local torso = PlayerControl.GetRootPart()
  2998. local rootPart = PlayerControl.GetRootPart()
  2999. if rootPart then
  3000. if PlayerControl.characterEnabled then
  3001. local torso_cframe = Camera.Focus:toWorldSpace(PlayerControl.hide_torso_object_cframe)
  3002. PlayerControl.torso_cframe = torso_cframe
  3003. torso.CFrame = torso_cframe
  3004. rootPart.CFrame = torso_cframe
  3005. else
  3006. PlayerControl.hide_torso_object_cframe = Camera.Focus:toObjectSpace(rootPart.CFrame)
  3007. end
  3008. else
  3009. PlayerControl.torso_cframe = Camera.Focus
  3010. end
  3011. if PlayerControl.characterEnabled then
  3012. PlayerControl.CreateCharacter()
  3013. RunService.Stepped:wait()
  3014. coroutine.yield()
  3015. if not no_animation then
  3016. Network.TransmitServer("GraphicalEffects.CrystalRing({base_part = (...), crystal_color = BrickColor.new
  3017.  
  3018. (\"Institutional white\"), float_duration = 2})", PlayerControl.GetTorso())
  3019. end
  3020. else
  3021. Player.Character = nil
  3022. Camera.CameraType = "Fixed"
  3023. if not no_animation then
  3024. Network.TransmitServer("GraphicalEffects.CrystalRing({position = (...), crystal_color = BrickColor.new
  3025.  
  3026. (\"Institutional white\"), float_duration = 2})", PlayerControl.GetTorso().Position)
  3027. end
  3028. end
  3029. else
  3030. if state then
  3031. PlayerControl.CreateCharacter()
  3032. RunService.Stepped:wait()
  3033. coroutine.yield()
  3034. if not no_animation then
  3035. Network.TransmitServer("GraphicalEffects.CrystalRing({base_part = (...), crystal_color = BrickColor.new
  3036.  
  3037. (\"Institutional white\"), float_duration = 2})", PyramidCharacter.core)
  3038. end
  3039. else
  3040. PyramidCharacter.visible = false
  3041. if not no_animation then
  3042. Network.TransmitServer("GraphicalEffects.CrystalRing({position = (...), crystal_color = BrickColor.new
  3043.  
  3044. (\"Institutional white\"), float_duration = 2})", PyramidCharacter.core.Position)
  3045. end
  3046. end
  3047. end
  3048. end
  3049. end
  3050. function PlayerControl.SetFeatherfallEnabled(state)
  3051. state = not not state
  3052. if state ~= PlayerControl.featherfallEnabled then
  3053. PlayerControl.featherfallEnabled = state
  3054. if state then
  3055. Logger.print("Info", "Featherfall enabled in PlayerControl")
  3056. else
  3057. Logger.print("Info", "Featherfall disabled in PlayerControl")
  3058. end
  3059. end
  3060. end
  3061. function PlayerControl.SetPushable(state)
  3062. state = not not state
  3063. if state ~= PlayerControl.pushable then
  3064. PlayerControl.pushable = state
  3065. if state then
  3066. Logger.print("Info", "Pushing enabled in PlayerControl")
  3067. else
  3068. Logger.print("Info", "Pushing disabled in PlayerControl")
  3069. end
  3070. end
  3071. end
  3072. function PlayerControl.SetRolling(state)
  3073. state = not not state
  3074. if state ~= PlayerControl.rolling then
  3075. PlayerControl.rolling = state
  3076. if state then
  3077. Logger.print("Info", "Rolling fly mode enabled in PlayerControl")
  3078. else
  3079. Logger.print("Info", "Rolling fly mode disabled in PlayerControl")
  3080. end
  3081. end
  3082. end
  3083. function PlayerControl.StartFlying()
  3084. PlayerControl.fly_speed = PlayerControl.fly_basespeed
  3085. if torso then
  3086. flyingMomentum = torso.Velocity + torso.CFrame.lookVector * 3 + Vector3.new(0, 10, 0)
  3087. else
  3088. flyingMomentum = Vector3.new()
  3089. end
  3090. flyingTilt = 0
  3091. flying = true
  3092. end
  3093. function PlayerControl.StopFlying()
  3094. if bodyGyro.cframe then
  3095. local lookVector = bodyGyro.cframe.lookVector
  3096. if lookVector.X ~= 0 or lookVector.Z ~= 0 then
  3097. bodyGyro.cframe = CFrame.new(Vector3.new(), Vector3.new(lookVector.X, 0, lookVector.Z))
  3098. end
  3099. end
  3100. flying = false
  3101. end
  3102. local previousTime = 0
  3103. UserInterface.SetHotkey(" ", function()
  3104. if flying then
  3105. PlayerControl.StopFlying()
  3106. else
  3107. local currentTime = time()
  3108. if currentTime - previousTime < 0.4 then
  3109. previousTime = 0
  3110. PlayerControl.StartFlying()
  3111. else
  3112. previousTime = currentTime
  3113. end
  3114. end
  3115. end)
  3116. ]])
  3117. Module.Create("RBXInstance", [[
  3118. RBXInstance.init_metatable = {}
  3119. function RBXInstance.init_metatable:__call(data)
  3120. local instance = Instance.new(self[1])
  3121. for key, value in pairs(data) do
  3122. if type(key) == "number" then
  3123. value.Parent = instance
  3124. else
  3125. instance[key] = value
  3126. end
  3127. end
  3128. return instance
  3129. end
  3130. function RBXInstance.new(className)
  3131. return setmetatable({className}, RBXInstance.init_metatable)
  3132. end
  3133. ]])
  3134. Module.Create("AdvancedGUI", [=[
  3135. if not AdvancedGUI.GUI_BASE_COLOR then
  3136. AdvancedGUI.GUI_BASE_COLOR = Color3.new(0, 0, 0)
  3137. end
  3138. function AdvancedGUI.GenerateChatColor(speakerName)
  3139. local chatColor = ChatColor.Get(speakerName).Color
  3140. local brightness = chatColor.r + chatColor.g + chatColor.b
  3141. if brightness < 1.5 then
  3142. chatColor = Color3.new(math.min(1, 0.4 + chatColor.r), math.min(1, 0.4 + chatColor.g), math.min(1, 0.4 + chatColor.b))
  3143. else
  3144. chatColor = Color3.new(math.min(1, 0.05 + chatColor.r), math.min(1, 0.05 + chatColor.g), math.min(1, 0.05 + chatColor.b))
  3145. end
  3146. return chatColor
  3147. end
  3148. GuiBase = {}
  3149. GuiBase.__index = GuiBase
  3150. function GuiBase:new(data)
  3151. local instance = setmetatable({}, self)
  3152. instance:Init(data)
  3153. return instance
  3154. end
  3155. function GuiBase:Destroy()
  3156. if self.parent then
  3157. self.parent.children[self] = nil
  3158. end
  3159. for child in pairs(self.children) do
  3160. child:Destroy()
  3161. end
  3162. self.m_base_instance:Destroy()
  3163. end
  3164. function GuiBase:GetContentInstance(child)
  3165. return self.m_base_instance
  3166. end
  3167. function GuiBase:Init()
  3168. self.children = {}
  3169. end
  3170. function GuiBase:IsA(className)
  3171. return className == "GuiBase"
  3172. end
  3173. function GuiBase:SetParent(parent)
  3174. if parent ~= self.parent then
  3175. if self.parent then
  3176. self.parent.children[self] = nil
  3177. end
  3178. self.parent = parent
  3179. if parent then
  3180. parent.children[self] = true
  3181. self.m_base_instance.Parent = parent:GetContentInstance()
  3182. else
  3183. self.m_base_instance.Parent = nil
  3184. end
  3185. end
  3186. end
  3187. GuiObject = setmetatable({}, GuiBase)
  3188. GuiObject.__index = GuiObject
  3189. function GuiObject:Destroy()
  3190. self.DragBegin:disconnect()
  3191. self.DragMove:disconnect()
  3192. self.DragStopped:disconnect()
  3193. self.MouseButton1Click:disconnect()
  3194. self.MouseButton1Down:disconnect()
  3195. self.MouseButton1Up:disconnect()
  3196. self.MouseButton2Down:disconnect()
  3197. self.MouseButton2Up:disconnect()
  3198. self.MouseEnter:disconnect()
  3199. self.MouseLeave:disconnect()
  3200. GuiBase.Destroy(self)
  3201. end
  3202. function GuiObject:GetAbsolutePosition()
  3203. return self.m_base_instance.AbsolutePosition
  3204. end
  3205. function GuiObject:GetAbsoluteSize()
  3206. return self.m_base_instance.AbsoluteSize
  3207. end
  3208. function GuiObject:GetPosition()
  3209. return self.position
  3210. end
  3211. function GuiObject:GetSize()
  3212. return self.size
  3213. end
  3214. function GuiObject:Init()
  3215. GuiBase.Init(self)
  3216. self.mouseDown = false
  3217. self.mouseOver = false
  3218. self.DragBegin = RbxUtility.CreateSignal()
  3219. self.DragMove = RbxUtility.CreateSignal()
  3220. self.DragStopped = RbxUtility.CreateSignal()
  3221. self.MouseButton1Click = RbxUtility.CreateSignal()
  3222. self.MouseButton1Down = RbxUtility.CreateSignal()
  3223. self.MouseButton1Up = RbxUtility.CreateSignal()
  3224. self.MouseButton2Down = RbxUtility.CreateSignal()
  3225. self.MouseButton2Up = RbxUtility.CreateSignal()
  3226. self.MouseEnter = RbxUtility.CreateSignal()
  3227. self.MouseLeave = RbxUtility.CreateSignal()
  3228. end
  3229. function GuiObject:IsA(className)
  3230. return className == "GuiObject" or GuiBase.IsA(self, className)
  3231. end
  3232. function GuiObject:SetActive(active)
  3233. if active ~= self.active then
  3234. self.active = active
  3235. end
  3236. end
  3237. function GuiObject:SetBackgroundTransparency(backgroundTransparency)
  3238. if backgroundTransparency ~= self.backgroundTransparency then
  3239. self.backgroundTransparency = backgroundTransparency
  3240. self.m_base_instance.BackgroundTransparency = backgroundTransparency
  3241. end
  3242. end
  3243. function GuiObject:SetColor(color)
  3244. if color ~= self.color then
  3245. self.color = color
  3246. self.m_base_instance.BackgroundColor3 = color
  3247. end
  3248. end
  3249. function GuiObject:SetPosition(position)
  3250. if position ~= self.position then
  3251. self.position = position
  3252. self.m_base_instance.Position = position
  3253. end
  3254. end
  3255. function GuiObject:SetSize(size)
  3256. if size ~= self.size then
  3257. self.size = size
  3258. self.m_base_instance.Size = size
  3259. end
  3260. end
  3261. function GuiObject:SetVisible(visible)
  3262. if visible ~= self.visible then
  3263. self.visible = visible
  3264. self.m_base_instance.Visible = visible
  3265. end
  3266. end
  3267. function GuiObject:SetZIndex(zIndex)
  3268. local stack = {self.m_base_instance}
  3269. repeat
  3270. local object = stack[#stack]
  3271. stack[#stack] = nil
  3272. for _, child in ipairs(object:GetChildren()) do
  3273. stack[#stack + 1] = child
  3274. end
  3275. object.ZIndex = zIndex
  3276. until #stack == 0
  3277. end
  3278. GuiServiceClass = setmetatable({}, GuiBase)
  3279. GuiServiceClass.__index = GuiServiceClass
  3280. function GuiServiceClass:CreateTextArea(text, font, fontSize, textColor3, textXAlignment, textYAlignment, maxWidth, minWidth)
  3281. local totalHeight = 0
  3282. local frame = Instance.new("Frame")
  3283. frame.BackgroundTransparency = 1
  3284. local label = Instance.new("TextLabel")
  3285. label.BackgroundTransparency = 1
  3286. label.Font = font
  3287. label.FontSize = fontSize
  3288. label.TextColor3 = textColor3
  3289. label.TextTransparency = 1
  3290. label.TextWrapped = true
  3291. label.TextXAlignment = textXAlignment
  3292. label.TextYAlignment = textYAlignment
  3293. label.Parent = self.guiFrame
  3294. local index = 1
  3295. while true do
  3296. local length = #text - index + 1
  3297. if length > 1024 then
  3298. length = 1024
  3299. local textBlock = string.sub(text, index, index + length - 1)
  3300. label.Text = textBlock
  3301. local height = 0
  3302. local width = maxWidth
  3303. repeat
  3304. height = height + 20
  3305. label.Size = UDim2.new(0, width, 0, height)
  3306. until label.TextFits
  3307. repeat
  3308. height = height - 1
  3309. label.Size = UDim2.new(0, width, 0, height)
  3310. until not label.TextFits
  3311. repeat
  3312. length = length - 10
  3313. label.Text = string.sub(text, index, index + length - 1)
  3314. until label.TextFits
  3315. repeat
  3316. length = length + 1
  3317. label.Text = string.sub(text, index, index + length - 1)
  3318. until not label.TextFits
  3319. local overflowCharacter = string.sub(text, index + length - 1, index + length - 1)
  3320. length = length - 1
  3321. label.Text = string.sub(text, index, index + length - 1)
  3322. if overflowCharacter == "\n" then
  3323. index = index + 1
  3324. end
  3325. repeat
  3326. height = height - 1
  3327. label.Size = UDim2.new(0, width, 0, height)
  3328. until not label.TextFits
  3329. height = height + 1
  3330. local blockLabel = label:Clone()
  3331. blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
  3332. blockLabel.Size = UDim2.new(1, 0, 0, height)
  3333. blockLabel.Parent = frame
  3334. totalHeight = totalHeight + height
  3335. index = index + length
  3336. else
  3337. local textBlock = string.sub(text, index)
  3338. label.Text = textBlock
  3339. local height = 0
  3340. local width = maxWidth
  3341. repeat
  3342. height = height + 20
  3343. label.Size = UDim2.new(0, width, 0, height)
  3344. until label.TextFits
  3345. repeat
  3346. height = height - 1
  3347. label.Size = UDim2.new(0, width, 0, height)
  3348. until not label.TextFits
  3349. height = height + 1
  3350. if index == 1 then
  3351. repeat
  3352. width = width - 10
  3353. label.Size = UDim2.new(0, width, 0, height)
  3354. until width < minWidth or not label.TextFits
  3355. width = math.max(width, minWidth - 1)
  3356. repeat
  3357. width = width + 1
  3358. label.Size = UDim2.new(0, width, 0, height)
  3359. until label.TextFits
  3360. end
  3361. local blockLabel = label:Clone()
  3362. blockLabel.Position = UDim2.new(0, 0, 0, totalHeight)
  3363. blockLabel.Size = UDim2.new(1, 0, 0, height)
  3364. blockLabel.Parent = frame
  3365. label:Destroy()
  3366. frame.Size = UDim2.new(0, width, 0, totalHeight + height)
  3367. return frame
  3368. end
  3369. end
  3370. end
  3371. function GuiServiceClass:Destroy()
  3372. self.running = false
  3373. self.cameraPart:Destroy()
  3374. self.cameraConnection:disconnect()
  3375. self.keyDownConnection:disconnect()
  3376. self.mouseButton1DownConnection:disconnect()
  3377. self.mouseButton1UpConnection:disconnect()
  3378. self.mouseButton2DownConnection:disconnect()
  3379. self.mouseButton2UpConnection:disconnect()
  3380. self.mouseMoveConnection:disconnect()
  3381. self.steppedConnection:disconnect()
  3382. end
  3383. function GuiServiceClass:GetMousePosition()
  3384. local mouse = self.mouse
  3385. return mouse.X, mouse.Y -- mouse.X, mouse.Y + 2 -- return mouse.X - 2, mouse.Y - 3
  3386. end
  3387. function GuiServiceClass:GetTextBounds(text, font, fontSize, alignX, alignY, width)
  3388. local tempLabel = self.tempLabel
  3389. tempLabel.Font = font
  3390. tempLabel.FontSize = fontSize
  3391. tempLabel.Size = UDim2.new(0, width, 0, 4096)
  3392. tempLabel.Text = text
  3393. tempLabel.TextXAlignment = alignX
  3394. tempLabel.TextYAlignment = alignY
  3395. local textBounds = tempLabel.TextBounds
  3396. tempLabel.Text = ""
  3397. return textBounds
  3398. end
  3399. function GuiServiceClass:Init(data)
  3400. GuiBase.Init(self)
  3401. local _ = string.char
  3402. local camera = data.Camera
  3403. local mouse = data.Mouse
  3404. local cameraPart = Instance.new("Part")
  3405. local billboardGui = Instance.new("BillboardGui", cameraPart)
  3406. guiFrame = Instance.new("Frame", billboardGui)
  3407. cameraPart.Anchored = true
  3408. cameraPart.BottomSurface = "Smooth"
  3409. cameraPart.CanCollide = false
  3410. -- cameraPart.CFrame = CFrame.new(16384, 16384, 16384)
  3411. cameraPart.FormFactor = "Custom"
  3412. cameraPart.Locked = true
  3413. cameraPart.Size = Vector3.new(0.2, 0.2, 0.2)
  3414. cameraPart.TopSurface = "Smooth"
  3415. cameraPart.Transparency = 1
  3416. billboardGui.Adornee = cameraPart
  3417. billboardGui.AlwaysOnTop = true
  3418. -- billboardGui.ExtentsOffset = Vector3.new(-16384, -16384, -16384)
  3419. guiFrame.BackgroundTransparency = 1
  3420. cameraPart.Parent = camera
  3421. self.running = true
  3422. self.m_base_instance = guiFrame
  3423. self.billboardGui = billboardGui
  3424. self.cameraPart = cameraPart
  3425. self.tempLabel = RBXInstance.new "TextLabel" {
  3426. BackgroundTransparency = 1,
  3427. TextTransparency = 1,
  3428. TextWrapped = true,
  3429. Parent = guiFrame
  3430. }
  3431. self.mnemonics = {}
  3432. self.visible = true
  3433. self.camera = camera
  3434. self.mouse = mouse
  3435. self.cameraConnection = camera.Changed:connect(function(property)
  3436. self:UpdateView()
  3437. if property == "CameraType" then
  3438. if camera.CameraType ~= Enum.CameraType.Track and camera.CameraType ~= Enum.CameraType.Fixed then
  3439. camera.CameraType = Enum.CameraType.Track
  3440. end
  3441. elseif property == "CoordinateFrame" and camera.CameraType ~= Enum.CameraType.Fixed then
  3442. local cframe, focus = camera.CoordinateFrame, camera.Focus
  3443. local watchOffset = focus.p - cframe.p
  3444. local error = watchOffset.unit - cframe.lookVector
  3445. if error.magnitude >= 1e-3 then
  3446. local head = PlayerControl.GetHead()
  3447. local time1, velocity1
  3448. if head then
  3449. time1 = time()
  3450. velocity1 = head.Velocity
  3451. end
  3452. if camera.Changed:wait() == "CoordinateFrame" then
  3453. local position = cframe.p
  3454. if head then
  3455. local time2 = time()
  3456. local velocity2 = head.Velocity
  3457. position = position + 0.5 * (velocity1 + velocity2) * (time2 - time1)
  3458. end
  3459. camera.CoordinateFrame = CFrame.new(position, camera.Focus.p)
  3460. end
  3461. end
  3462. end
  3463. end)
  3464. self.keyDownConnection = mouse.KeyDown:connect(function(key) self:KeyDown(key) end)
  3465. self.mouseButton1DownConnection = mouse.Button1Down:connect(function() self:MouseButton1Down() end)
  3466. self.mouseButton1UpConnection = mouse.Button1Up:connect(function() self:MouseButton1Up() end)
  3467. self.mouseButton2DownConnection = mouse.Button2Down:connect(function() self:MouseButton2Down() end)
  3468. self.mouseButton2UpConnection = mouse.Button2Up:connect(function() self:MouseButton2Up() end)
  3469. self.mouseMoveConnection = mouse.Move:connect(function() self:MouseMove() end)
  3470. self.steppedConnection = RunService.RenderStepped:connect(function() self:UpdateObjects() self:UpdateView() end)
  3471. self.mousePreviousPosition = Vector2.new(self:GetMousePosition())
  3472. end
  3473. function GuiServiceClass:IsA(className)
  3474. return className == "GuiService" or GuiBase.IsA(self, className)
  3475. end
  3476. function GuiServiceClass:KeyDown(key)
  3477. local mnemonicButton = self.mnemonics[string.upper(key)]
  3478. if mnemonicButton then
  3479. mnemonicButton.Activated:fire()
  3480. end
  3481. end
  3482. function GuiServiceClass:MouseButton1Down()
  3483. local mouse = self.mouse
  3484. local mouseX, mouseY = self:GetMousePosition()
  3485. local stack = {self}
  3486. local dragObjects = {}
  3487. self.dragObjects = dragObjects
  3488. while #stack > 0 do
  3489. local object = stack[#stack]
  3490. stack[#stack] = nil
  3491. if object.visible then
  3492. for child in pairs(object.children) do
  3493. stack[#stack + 1] = child
  3494. end
  3495. if object.active then
  3496. local position = object:GetAbsolutePosition()
  3497. local size = object:GetAbsoluteSize()
  3498. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3499. object.mouseDown = true
  3500. dragObjects[object] = true
  3501. local mouseButton1Down = object.MouseButton1Down
  3502. if mouseButton1Down then
  3503. mouseButton1Down:fire()
  3504. if object.autoButtonColor then
  3505. local color = object.color
  3506. local transparency = object.backgroundTransparency
  3507. object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g +
  3508.  
  3509. 0.3, 1), math.min(color.b + 0.3, 1))
  3510. object.m_base_instance.BackgroundTransparency = transparency
  3511. end
  3512. end
  3513. object.DragBegin:fire()
  3514. end
  3515. end
  3516. end
  3517. end
  3518. self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
  3519. end
  3520. function GuiServiceClass:MouseButton1Up()
  3521. local mouse = self.mouse
  3522. local mouseX, mouseY = self:GetMousePosition()
  3523. local stack = {self}
  3524. while #stack > 0 do
  3525. local object = stack[#stack]
  3526. stack[#stack] = nil
  3527. if object.visible then
  3528. for child in pairs(object.children) do
  3529. stack[#stack + 1] = child
  3530. end
  3531. if object.active then
  3532. local position = object:GetAbsolutePosition()
  3533. local size = object:GetAbsoluteSize()
  3534. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3535. object.MouseButton1Up:fire()
  3536. end
  3537. end
  3538. end
  3539. end
  3540. local dragObjects = self.dragObjects
  3541. self.dragObjects = nil
  3542. if dragObjects then
  3543. for dragObject in pairs(dragObjects) do
  3544. dragObject.mouseDown = false
  3545. local position = dragObject:GetAbsolutePosition()
  3546. local size = dragObject:GetAbsoluteSize()
  3547. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3548. dragObject.MouseButton1Click:fire()
  3549. local activated = dragObject.Activated
  3550. if activated then
  3551. activated:fire()
  3552. end
  3553. end
  3554. dragObject.DragStopped:fire()
  3555. if dragObject.autoButtonColor then
  3556. if dragObject.mouseOver then
  3557. local color = dragObject.color
  3558. local transparency = dragObject.backgroundTransparency
  3559. dragObject.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0),
  3560.  
  3561. math.max(color.b - 0.3, 0))
  3562. dragObject.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
  3563. else
  3564. dragObject.m_base_instance.BackgroundColor3 = dragObject.color
  3565. dragObject.m_base_instance.BackgroundTransparency = dragObject.backgroundTransparency
  3566. end
  3567. end
  3568. self.dragObject = nil
  3569. end
  3570. end
  3571. end
  3572. function GuiServiceClass:MouseButton2Down()
  3573. local mouse = self.mouse
  3574. local mouseX, mouseY = self:GetMousePosition()
  3575. local stack = {self}
  3576. while #stack > 0 do
  3577. local object = stack[#stack]
  3578. stack[#stack] = nil
  3579. if object.visible then
  3580. for child in pairs(object.children) do
  3581. stack[#stack + 1] = child
  3582. end
  3583. if object.active then
  3584. local position = object:GetAbsolutePosition()
  3585. local size = object:GetAbsoluteSize()
  3586. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3587. local mouseButton2Down = object.MouseButton2Down
  3588. if mouseButton2Down then
  3589. mouseButton2Down:fire()
  3590. end
  3591. end
  3592. end
  3593. end
  3594. end
  3595. self.mousePreviousPosition = Vector2.new(mouseX, mouseY)
  3596. end
  3597. function GuiServiceClass:MouseButton2Up()
  3598. local mouse = self.mouse
  3599. local mouseX, mouseY = self:GetMousePosition()
  3600. local stack = {self}
  3601. while #stack > 0 do
  3602. local object = stack[#stack]
  3603. stack[#stack] = nil
  3604. if object.visible then
  3605. for child in pairs(object.children) do
  3606. stack[#stack + 1] = child
  3607. end
  3608. if object.active then
  3609. local position = object:GetAbsolutePosition()
  3610. local size = object:GetAbsoluteSize()
  3611. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3612. local mouseButton2Up = object.MouseButton2Up
  3613. if mouseButton2Up then
  3614. mouseButton2Up:fire()
  3615. end
  3616. end
  3617. end
  3618. end
  3619. end
  3620. end
  3621. function GuiServiceClass:MouseMove()
  3622. self:UpdateObjects()
  3623. local dragObjects = self.dragObjects
  3624. if dragObjects then
  3625. for dragObject in pairs(dragObjects) do
  3626. local mouse = self.mouse
  3627. local mousePosition = Vector2.new(self:GetMousePosition())
  3628. dragObject.DragMove:fire(mousePosition - self.mousePreviousPosition)
  3629. self.mousePreviousPosition = mousePosition
  3630. end
  3631. end
  3632. end
  3633. function GuiServiceClass:SetMnemonic(mnemonic, button)
  3634. self.mnemonics[mnemonic] = button
  3635. end
  3636. function GuiServiceClass:UpdateObjects()
  3637. local mouse = self.mouse
  3638. local mouseX, mouseY = self:GetMousePosition()
  3639. local stack = {self}
  3640. while #stack > 0 do
  3641. local object = stack[#stack]
  3642. stack[#stack] = nil
  3643. if object.visible then
  3644. for child in pairs(object.children) do
  3645. stack[#stack + 1] = child
  3646. end
  3647. if object.active then
  3648. local position = object:GetAbsolutePosition()
  3649. local size = object:GetAbsoluteSize()
  3650. if mouseX >= position.X and mouseY >= position.Y and mouseX < position.X + size.X and mouseY < position.Y + size.Y then
  3651. if not object.mouseOver then
  3652. object.mouseOver = true
  3653. object.MouseEnter:fire()
  3654. if object.autoButtonColor then
  3655. local color = object.color
  3656. local transparency = object.backgroundTransparency
  3657. if object.mouseDown then
  3658. object.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min
  3659.  
  3660. (color.g + 0.3, 1), math.min(color.b + 0.3, 1))
  3661. object.m_base_instance.BackgroundTransparency = transparency
  3662. else
  3663. object.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max
  3664.  
  3665. (color.g - 0.3, 0), math.max(color.b - 0.3, 0))
  3666. object.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.2)
  3667. end
  3668. end
  3669. end
  3670. else
  3671. if object.mouseOver then
  3672. object.mouseOver = false
  3673. object.MouseLeave:fire()
  3674. if object.autoButtonColor then
  3675. object.m_base_instance.BackgroundColor3 = object.color
  3676. object.m_base_instance.BackgroundTransparency = object.backgroundTransparency
  3677. end
  3678. end
  3679. end
  3680. end
  3681. end
  3682. end
  3683. end
  3684. function GuiServiceClass:UpdateView()
  3685. local billboardGui = self.billboardGui
  3686. local guiFrame = self.m_base_instance
  3687. local camera = self.camera
  3688. local mouse = self.mouse
  3689. local cameraCFrame = CFrame.new(camera.CoordinateFrame.p, camera.Focus.p) -- camera.CoordinateFrame
  3690. local viewSizeX, viewSizeY = mouse.ViewSizeX, mouse.ViewSizeY
  3691. local previousViewSize = self.viewSize
  3692. if not previousViewSize or ((viewSizeX ~= 0 or viewSizeY ~= 0) and (viewSizeX ~= previousViewSize.X or viewSizeY ~= previousViewSize.Y)) then
  3693. self.viewSize = {X = viewSizeX, Y = viewSizeY}
  3694. local viewSizeUDim2 = UDim2.new(0, viewSizeX, 0, viewSizeY)
  3695. billboardGui.Size = viewSizeUDim2
  3696. guiFrame.Size = viewSizeUDim2
  3697. -- FIXME:
  3698. -- After the 15th of July 2014, there came an offset at the Y thingy out of nowhere so I accomodated for that.
  3699. billboardGui.SizeOffset = Vector2.new(0.5 / viewSizeX, (0.5 + 10) / viewSizeY)
  3700. end
  3701. --billboardGui.SizeOffset = Vector2.new()
  3702. billboardGui.StudsOffset = (cameraCFrame - cameraCFrame.p):inverse() * cameraCFrame.p - Vector3.new(0, 0, 1)
  3703. end
  3704. GuiService = GuiServiceClass:new {
  3705. Camera = Camera,
  3706. Mouse = Mouse
  3707. }
  3708. GuiFrame = setmetatable({}, GuiObject)
  3709. GuiFrame.__index = GuiFrame
  3710. GuiFrame.__default = {__index = {
  3711. Active = false,
  3712. BackgroundTransparency = 0.75,
  3713. BorderSize = 4,
  3714. BorderTransparency = 0.75,
  3715. Color = AdvancedGUI.GUI_BASE_COLOR,
  3716. Position = UDim2.new(0, 0, 0, 0),
  3717. Size = UDim2.new(0, 52, 0, 52),
  3718. Visible = true
  3719. }}
  3720. function GuiFrame:Destroy()
  3721. GuiObject.Destroy(self)
  3722. end
  3723. function GuiFrame:GetContentInstance()
  3724. return self.m_content_frame
  3725. end
  3726. function GuiFrame:Init(data)
  3727. GuiObject.Init(self)
  3728. setmetatable(data, GuiFrame.__default)
  3729. local leftBorderFrameLeft = RBXInstance.new "Frame" {
  3730. BackgroundColor3 = Color3.new(0, 0, 0),
  3731. BorderSizePixel = 0,
  3732. Size = UDim2.new(0, 1, 1, -1)
  3733. }
  3734. local leftBorderFrameCenter = RBXInstance.new "Frame" {
  3735. BackgroundColor3 = Color3.new(1, 1, 1),
  3736. BorderSizePixel = 0,
  3737. Position = UDim2.new(0, 1, 0, 1)
  3738. }
  3739. local leftBorderFrameRight = RBXInstance.new "Frame" {
  3740. BackgroundColor3 = Color3.new(0, 0, 0),
  3741. BorderSizePixel = 0
  3742. }
  3743. local rightBorderFrameRight = RBXInstance.new "Frame" {
  3744. BackgroundColor3 = Color3.new(0, 0, 0),
  3745. BorderSizePixel = 0,
  3746. Position = UDim2.new(1, -1, 0, 1),
  3747. Size = UDim2.new(0, 1, 1, -1)
  3748. }
  3749. local rightBorderFrameCenter = RBXInstance.new "Frame" {
  3750. BackgroundColor3 = Color3.new(1, 1, 1),
  3751. BorderSizePixel = 0
  3752. }
  3753. local rightBorderFrameLeft = RBXInstance.new "Frame" {
  3754. BackgroundColor3 = Color3.new(0, 0, 0),
  3755. BorderSizePixel = 0
  3756. }
  3757. local bottomBorderFrameBottom = RBXInstance.new "Frame" {
  3758. BackgroundColor3 = Color3.new(0, 0, 0),
  3759. BorderSizePixel = 0,
  3760. Position = UDim2.new(0, 0, 1, -1),
  3761. Size = UDim2.new(1, -1, 0, 1)
  3762. }
  3763. local bottomBorderFrameCenter = RBXInstance.new "Frame" {
  3764. BackgroundColor3 = Color3.new(1, 1, 1),
  3765. BorderSizePixel = 0
  3766. }
  3767. local bottomBorderFrameTop = RBXInstance.new "Frame" {
  3768. BackgroundColor3 = Color3.new(0, 0, 0),
  3769. BorderSizePixel = 0
  3770. }
  3771. local topBorderFrameTop = RBXInstance.new "Frame" {
  3772. BackgroundColor3 = Color3.new(0, 0, 0),
  3773. BorderSizePixel = 0,
  3774. Position = UDim2.new(0, 1, 0, 0),
  3775. Size = UDim2.new(1, -1, 0, 1)
  3776. }
  3777. local topBorderFrameCenter = RBXInstance.new "Frame" {
  3778. BackgroundColor3 = Color3.new(1, 1, 1),
  3779. BorderSizePixel = 0
  3780. }
  3781. local topBorderFrameBottom = RBXInstance.new "Frame" {
  3782. BackgroundColor3 = Color3.new(0, 0, 0),
  3783. BorderSizePixel = 0
  3784. }
  3785. local border_frame = RBXInstance.new "Frame" {
  3786. BackgroundTransparency = 1,
  3787. Size = UDim2.new(1, 0, 1, 0),
  3788. leftBorderFrameLeft,
  3789. leftBorderFrameCenter,
  3790. leftBorderFrameRight,
  3791. rightBorderFrameLeft,
  3792. rightBorderFrameCenter,
  3793. rightBorderFrameRight,
  3794. bottomBorderFrameBottom,
  3795. bottomBorderFrameCenter,
  3796. bottomBorderFrameTop,
  3797. topBorderFrameBottom,
  3798. topBorderFrameCenter,
  3799. topBorderFrameTop
  3800. }
  3801. local contentFrame = RBXInstance.new "Frame" {
  3802. BackgroundTransparency = 1,
  3803. BorderSizePixel = 0,
  3804. ClipsDescendants = true,
  3805. Size = UDim2.new(1, 0, 1, 0)
  3806. }
  3807. local base_frame = RBXInstance.new "Frame" {
  3808. BorderSizePixel = 0,
  3809. border_frame,
  3810. contentFrame
  3811. }
  3812. self.m_base_instance = base_frame
  3813. self.m_content_frame = contentFrame
  3814. self.m_border_frame = border_frame
  3815. self.leftBorderFrameLeft = leftBorderFrameLeft
  3816. self.leftBorderFrameCenter = leftBorderFrameCenter
  3817. self.leftBorderFrameRight = leftBorderFrameRight
  3818. self.rightBorderFrameLeft = rightBorderFrameLeft
  3819. self.rightBorderFrameCenter = rightBorderFrameCenter
  3820. self.rightBorderFrameRight = rightBorderFrameRight
  3821. self.bottomBorderFrameBottom = bottomBorderFrameBottom
  3822. self.bottomBorderFrameCenter = bottomBorderFrameCenter
  3823. self.bottomBorderFrameTop = bottomBorderFrameTop
  3824. self.topBorderFrameBottom = topBorderFrameBottom
  3825. self.topBorderFrameCenter = topBorderFrameCenter
  3826. self.topBorderFrameTop = topBorderFrameTop
  3827. self:SetActive(data.Active)
  3828. self:SetBackgroundTransparency(data.BackgroundTransparency)
  3829. self:SetBorderSize(data.BorderSize)
  3830. self:SetBorderTransparency(data.BorderTransparency)
  3831. self:SetColor(data.Color)
  3832. self:SetPosition(data.Position)
  3833. self:SetSize(data.Size)
  3834. self:SetVisible(data.Visible)
  3835. self:SetParent(data.Parent)
  3836. end
  3837. function GuiFrame:IsA(className)
  3838. return className == "GuiFrame" or GuiObject.IsA(self, className)
  3839. end
  3840. function GuiFrame:SetBorderSize(border_size)
  3841. border_size = math.max(math.floor(border_size + 0.5), 0)
  3842. if border_size ~= self.m_border_size then
  3843. self.m_border_size = border_size
  3844. local border_frame = self.m_border_frame
  3845. local contentFrame = self.m_content_frame
  3846. local leftBorderFrameCenter = self.leftBorderFrameCenter
  3847. local leftBorderFrameRight = self.leftBorderFrameRight
  3848. local rightBorderFrameCenter = self.rightBorderFrameCenter
  3849. local rightBorderFrameLeft = self.rightBorderFrameLeft
  3850. local bottomBorderFrameCenter = self.bottomBorderFrameCenter
  3851. local bottomBorderFrameTop = self.bottomBorderFrameTop
  3852. local topBorderFrameCenter = self.topBorderFrameCenter
  3853. local topBorderFrameBottom = self.topBorderFrameBottom
  3854. contentFrame.Position = UDim2.new(0, border_size, 0, border_size)
  3855. contentFrame.Size = UDim2.new(1, -2 * border_size, 1, -2 * border_size)
  3856. local inner_visible = border_size > 0
  3857. if self.leftBorderFrameLeft.Visible ~= inner_visible then
  3858. self.rightBorderFrameRight.Visible = inner_visible
  3859. self.bottomBorderFrameBottom.Visible = inner_visible
  3860. self.topBorderFrameTop.Visible = inner_visible
  3861. end
  3862. local outer_visible = border_size > 1
  3863. if leftBorderFrameCenter.Visible ~= outer_visible then
  3864. leftBorderFrameCenter.Visible = outer_visible
  3865. leftBorderFrameRight.Visible = outer_visible
  3866. rightBorderFrameCenter.Visible = outer_visible
  3867. rightBorderFrameLeft.Visible = outer_visible
  3868. bottomBorderFrameCenter.Visible = outer_visible
  3869. bottomBorderFrameTop.Visible = outer_visible
  3870. topBorderFrameCenter.Visible = outer_visible
  3871. topBorderFrameBottom.Visible = outer_visible
  3872. end
  3873. if outer_visible then
  3874. leftBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
  3875. leftBorderFrameRight.Position = UDim2.new(0, border_size - 1, 0, border_size - 1)
  3876. leftBorderFrameRight.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
  3877. rightBorderFrameCenter.Position = UDim2.new(1, 1 - border_size, 0, border_size - 1)
  3878. rightBorderFrameCenter.Size = UDim2.new(0, border_size - 2, 1, -border_size)
  3879. rightBorderFrameLeft.Position = UDim2.new(1, -border_size, 0, border_size)
  3880. rightBorderFrameLeft.Size = UDim2.new(0, 1, 1, 1 - 2 * border_size)
  3881. bottomBorderFrameCenter.Position = UDim2.new(0, 1, 1, 1 - border_size)
  3882. bottomBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
  3883. bottomBorderFrameTop.Position = UDim2.new(0, border_size - 1, 1, -border_size)
  3884. bottomBorderFrameTop.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
  3885. topBorderFrameCenter.Position = UDim2.new(0, border_size - 1, 0, 1)
  3886. topBorderFrameCenter.Size = UDim2.new(1, -border_size, 0, border_size - 2)
  3887. topBorderFrameBottom.Position = UDim2.new(0, border_size, 0, border_size - 1)
  3888. topBorderFrameBottom.Size = UDim2.new(1, 1 - 2 * border_size, 0, 1)
  3889. end
  3890. end
  3891. end
  3892. function GuiFrame:SetBorderTransparency(borderTransparency)
  3893. self.borderTransparency = borderTransparency
  3894. self.leftBorderFrameLeft.BackgroundTransparency = borderTransparency
  3895. self.leftBorderFrameCenter.BackgroundTransparency = borderTransparency
  3896. self.leftBorderFrameRight.BackgroundTransparency = borderTransparency
  3897. self.rightBorderFrameLeft.BackgroundTransparency = borderTransparency
  3898. self.rightBorderFrameCenter.BackgroundTransparency = borderTransparency
  3899. self.rightBorderFrameRight.BackgroundTransparency = borderTransparency
  3900. self.bottomBorderFrameBottom.BackgroundTransparency = borderTransparency
  3901. self.bottomBorderFrameCenter.BackgroundTransparency = borderTransparency
  3902. self.bottomBorderFrameTop.BackgroundTransparency = borderTransparency
  3903. self.topBorderFrameBottom.BackgroundTransparency = borderTransparency
  3904. self.topBorderFrameCenter.BackgroundTransparency = borderTransparency
  3905. self.topBorderFrameTop.BackgroundTransparency = borderTransparency
  3906. end
  3907. GuiButton = setmetatable({}, GuiFrame)
  3908. GuiButton.__index = GuiButton
  3909. GuiButton.__default = {__index = {
  3910. AutoButtonColor = true
  3911. }}
  3912. function GuiButton:Destroy()
  3913. self.Activated:disconnect()
  3914. GuiFrame.Destroy(self)
  3915. end
  3916. function GuiButton:Init(data)
  3917. if data.Active == nil then
  3918. data.Active = true
  3919. end
  3920. GuiFrame.Init(self, data)
  3921. setmetatable(data, GuiButton.__default)
  3922. self.Activated = RbxUtility.CreateSignal()
  3923. self:SetAutoButtonColor(data.AutoButtonColor)
  3924. end
  3925. function GuiButton:IsA(className)
  3926. return className == "GuiButton" or GuiFrame.IsA(self, className)
  3927. end
  3928. function GuiButton:SetAutoButtonColor(autoButtonColor)
  3929. if autoButtonColor ~= self.autoButtonColor then
  3930. self.autoButtonColor = autoButtonColor
  3931. if autoButtonColor then
  3932. if self.mouseOver then
  3933. local color = self.color
  3934. local transparency = self.backgroundTransparency
  3935. if self.mouseDown then
  3936. self.m_base_instance.BackgroundColor3 = Color3.new(math.min(color.r + 0.3, 1), math.min(color.g + 0.3, 1), math.min
  3937.  
  3938. (color.b + 0.3, 1))
  3939. self.m_base_instance.BackgroundTransparency = transparency
  3940. else
  3941. self.m_base_instance.BackgroundColor3 = Color3.new(math.max(color.r - 0.3, 0), math.max(color.g - 0.3, 0), math.max
  3942.  
  3943. (color.b - 0.3, 0))
  3944. self.m_base_instance.BackgroundTransparency = math.max(0, transparency - 0.5)
  3945. end
  3946. end
  3947. else
  3948. self.m_base_instance.BackgroundColor3 = self.color
  3949. end
  3950. end
  3951. end
  3952. GuiTextLabel = setmetatable({}, GuiFrame)
  3953. GuiTextLabel.__index = GuiTextLabel
  3954. GuiTextLabel.__default = {__index = {
  3955. Font = "ArialBold",
  3956. FontSize = "Size12",
  3957. Text = "",
  3958. TextColor = Color3.new(1, 1, 1),
  3959. TextStrokeColor = Color3.new(0, 0, 0),
  3960. TextStrokeTransparency = 0.6,
  3961. TextWrapped = true
  3962. }}
  3963. function GuiTextLabel:Destroy()
  3964. GuiFrame.Destroy(self)
  3965. end
  3966. function GuiTextLabel:Init(data)
  3967. GuiFrame.Init(self, data)
  3968. setmetatable(data, GuiTextLabel.__default)
  3969. local base_instance = self.m_base_instance
  3970. local textLabel = RBXInstance.new "TextLabel" {
  3971. BackgroundTransparency = 1,
  3972. Font = data.Font,
  3973. FontSize = data.FontSize,
  3974. TextColor3 = data.TextColor3,
  3975. TextStrokeColor3 = data.TextStrokeColor3,
  3976. TextStrokeTransparency = data.TextStrokeTransparency,
  3977. TextWrapped = data.TextWrapped
  3978. }
  3979. textLabel.Parent = self:GetContentInstance()
  3980. self.textLabel = textLabel
  3981. self:SetText(data.Text)
  3982. end
  3983. function GuiTextLabel:IsA(className)
  3984. return className == "GuiTextLabel" or GuiFrame.IsA(self, className)
  3985. end
  3986. function GuiTextLabel:SetText(text)
  3987. if text ~= self.text then
  3988. self.text = text
  3989. local text_index = 1
  3990. local content_instance = self:GetContentInstance()
  3991. local content_instance_size = content_instance.AbsoluteSize
  3992. local frame = Instance.new("Frame")
  3993. frame.BackgroundTransparency = 1
  3994. local label = Instance.new("TextLabel")
  3995. label.BackgroundTransparency = 1
  3996. label.Font = font
  3997. label.FontSize = fontSize
  3998. label.Size = UDim2.new(0, content_instance_size.X, 0, 1000)
  3999. label.Text = ""
  4000. label.TextColor3 = textColor3
  4001. label.TextTransparency = 1
  4002. label.TextWrapped = true
  4003. label.TextXAlignment = textXAlignment
  4004. label.TextYAlignment = textYAlignment
  4005. label.Parent = self.guiFrame
  4006. local row_length = 0
  4007. local step_size = 256
  4008. for step = 1, 8 do
  4009. step_size = 0.5 * step_size
  4010. label.Text = string.sub(text, text_index, text_index + row_length - 1)
  4011. end
  4012. end
  4013. end
  4014. GuiImageButton = setmetatable({}, GuiButton)
  4015. GuiImageButton.__index = GuiImageButton
  4016. GuiImageButton.__default = {__index = {
  4017. Image = ""
  4018. }}
  4019. function GuiImageButton:Destroy()
  4020. GuiButton.Destroy(self)
  4021. end
  4022. function GuiImageButton:Init(data)
  4023. GuiButton.Init(self, data)
  4024. setmetatable(data, GuiImageButton.__default)
  4025. local content_frame = self.m_content_frame
  4026. local image_label = RBXInstance.new "ImageLabel" {
  4027. BackgroundTransparency = 1,
  4028. Size = UDim2.new(1, 0, 1, 0)
  4029. }
  4030. image_label.Parent = content_frame
  4031. self.m_image_label = image_label
  4032. self:SetImage(data.Image)
  4033. end
  4034. function GuiImageButton:IsA(className)
  4035. return className == "GuiImageButton" or GuiButton.IsA(self, className)
  4036. end
  4037. function GuiImageButton:SetImage(image)
  4038. if image ~= self.m_image then
  4039. self.m_image = image
  4040. self.m_image_label.Image = image
  4041. end
  4042. end
  4043. GuiTextButton = setmetatable({}, GuiButton)
  4044. GuiTextButton.__index = GuiTextButton
  4045. GuiTextButton.__default = {__index = {
  4046. Font = Enum.Font.ArialBold,
  4047. FontSize = Enum.FontSize.Size11,
  4048. Text = "Button",
  4049. TextXAlignment = Enum.TextXAlignment.Center
  4050. }}
  4051. function GuiTextButton:Destroy()
  4052. GuiButton.Destroy(self)
  4053. end
  4054. function GuiTextButton:GetTextBounds()
  4055. return self.textLabel.TextBounds
  4056. end
  4057. function GuiTextButton:Init(data)
  4058. GuiButton.Init(self, data)
  4059. setmetatable(data, GuiTextButton.__default)
  4060. local contentFrame = self.m_content_frame
  4061. local mnemonicLabel = RBXInstance.new "TextLabel" {
  4062. BackgroundTransparency = 1,
  4063. Font = "ArialBold",
  4064. FontSize = "Size36",
  4065. Size = UDim2.new(1, 0, 0.7, 0),
  4066. TextColor3 = Color3.new(1, 1, 1),
  4067. TextStrokeColor3 = Color3.new(0, 0, 0),
  4068. TextStrokeTransparency = 0.6,
  4069. TextWrapped = true
  4070. }
  4071. local textLabel = RBXInstance.new "TextLabel" {
  4072. BackgroundTransparency = 1,
  4073. TextColor3 = Color3.new(1, 1, 1),
  4074. TextStrokeColor3 = Color3.new(0, 0, 0),
  4075. TextStrokeTransparency = 0.6,
  4076. TextWrapped = true
  4077. }
  4078. mnemonicLabel.Parent = contentFrame
  4079. textLabel.Parent = contentFrame
  4080. self.mnemonicLabel = mnemonicLabel
  4081. self.textLabel = textLabel
  4082. self:SetFont(data.Font)
  4083. self:SetFontSize(data.FontSize)
  4084. self:SetMnemonic(data.Mnemonic, true)
  4085. self:SetText(data.Text)
  4086. self:SetTextXAlignment(data.TextXAlignment)
  4087. end
  4088. function GuiTextButton:IsA(className)
  4089. return className == "GuiTextButton" or GuiButton.IsA(self, className)
  4090. end
  4091. function GuiTextButton:SetFont(font)
  4092. if font ~= self.font then
  4093. self.font = font
  4094. self.textLabel.Font = font
  4095. end
  4096. end
  4097. function GuiTextButton:SetFontSize(fontSize)
  4098. if fontSize ~= self.fontSize then
  4099. self.fontSize = fontSize
  4100. self.textLabel.FontSize = fontSize
  4101. end
  4102. end
  4103. function GuiTextButton:SetMnemonic(mnemonic, forceUpdate)
  4104. if mnemonic ~= self.mnemonic or forceUpdate then
  4105. if self.mnemonic then
  4106. GuiService:SetMnemonic(self.mnemonic, nil)
  4107. end
  4108. if mnemonic then
  4109. GuiService:SetMnemonic(mnemonic, self)
  4110. end
  4111. self.mnemonic = mnemonic
  4112. local mnemonicLabel = self.mnemonicLabel
  4113. local textLabel = self.textLabel
  4114. if mnemonic then
  4115. mnemonicLabel.Text = mnemonic
  4116. textLabel.Size = UDim2.new(1, 0, 0.9, 0)
  4117. textLabel.TextYAlignment = "Bottom"
  4118. else
  4119. mnemonicLabel.Text = ""
  4120. textLabel.Size = UDim2.new(1, 0, 1, 0)
  4121. textLabel.TextYAlignment = "Center"
  4122. end
  4123. end
  4124. end
  4125. function GuiTextButton:SetText(text)
  4126. if text ~= self.text then
  4127. self.text = text
  4128. self.textLabel.Text = text
  4129. end
  4130. end
  4131. function GuiTextButton:SetTextXAlignment(textXAlignment)
  4132. if textXAlignment ~= self.textXAlignment then
  4133. self.textXAlignment = textXAlignment
  4134. self.textLabel.TextXAlignment = textXAlignment
  4135. end
  4136. end
  4137. GuiWindow = setmetatable({}, GuiObject)
  4138. GuiWindow.__index = GuiWindow
  4139. GuiWindow.__default = {__index = {
  4140. Active = true,
  4141. BackgroundTransparency = 0.5,
  4142. BorderSize = 4,
  4143. BorderTransparency = 0.5,
  4144. Position = UDim2.new(0, 0, 0, 0),
  4145. Size = UDim2.new(0, 360, 0, 240),
  4146. Title = "Window",
  4147. TitleBarBackgroundTransparency = 0.5,
  4148. TitleBarBorderTransparency = 1,
  4149. Visible = true
  4150. }}
  4151. function GuiWindow:Init(data)
  4152. GuiObject.Init(self)
  4153. setmetatable(data, GuiFrame.__default)
  4154. local title_bar = GuiTextLabel:new {
  4155. BackgroundTransparency = data.TitleBarBackgroundTransparency,
  4156. BorderTransparency = data.TitleBarBackgroundTransparency,
  4157. Text = data.Title
  4158. }
  4159. local content_frame = GuiFrame:new {
  4160. Active = data.Active,
  4161. BackgroundTransparency = data.BackgroundTransparency,
  4162. BorderSize = data.BorderSize,
  4163. BorderTransparency = data.BorderTransparency
  4164. }
  4165. local base_frame = RBXInstance.new "Frame" {
  4166. BackgroundTransparency = 1,
  4167. BorderSizePixel = 0,
  4168. Position = data.Position,
  4169. Size = data.Size,
  4170. Visible = data.Visible
  4171. }
  4172. self.m_base_frame = base_frame
  4173. self.m_content_frame = content_frame
  4174. self.m_title_bar = title_bar
  4175. end
  4176. function GuiWindow:IsA(className)
  4177. return className == "GuiWindow" or GuiObject.IsA(self, className)
  4178. end
  4179. GuiScrollFrame = setmetatable({}, GuiFrame)
  4180. GuiScrollFrame.__index = GuiScrollFrame
  4181. GuiScrollFrame.__default = {__index = {
  4182. ContentHeight = 0,
  4183. ScrollBarColor = Color3.new(1, 1, 1)
  4184. }}
  4185. function GuiScrollFrame:Destroy()
  4186. self.m_scroll_bar:Destroy()
  4187. GuiFrame.Destroy(self)
  4188. end
  4189. function GuiScrollFrame:GetContentInstance()
  4190. return self.m_scroll_frame or GuiFrame.GetContentInstance(self)
  4191. end
  4192. function GuiScrollFrame:Init(data)
  4193. GuiFrame.Init(self, data)
  4194. setmetatable(data, GuiScrollFrame.__default)
  4195. local scroll_pane = RBXInstance.new "Frame" {
  4196. BackgroundColor3 = Color3.new(1, 1, 1),
  4197. BackgroundTransparency = 0.8,
  4198. BorderSizePixel = 0,
  4199. Position = UDim2.new(1, -20, 0, 0),
  4200. Size = UDim2.new(0, 20, 1, 0),
  4201. Parent = self.m_content_frame
  4202. }
  4203. local scroll_bar = GuiFrame:new {
  4204. Active = true,
  4205. BackgroundTransparency = 0.6,
  4206. BorderTransparency = 0.6,
  4207. Color = data.ScrollBarColor,
  4208. Parent = self
  4209. }
  4210. local scroll_frame = RBXInstance.new "Frame" {
  4211. BackgroundTransparency = 1,
  4212. Parent = self.m_content_frame
  4213. }
  4214. self.m_scroll_bar = scroll_bar
  4215. self.m_scroll_frame = scroll_frame
  4216. self.m_scroll_pane = scroll_pane
  4217. self.m_scroll_position = 0
  4218. self.m_updating_content_height = false
  4219. self:SetContentHeight(data.ContentHeight)
  4220. self:UpdateScrollPosition()
  4221. self.m_scroll_bar.DragBegin:connect(function()
  4222. self.m_scroll_drag_total = Vector2.new()
  4223. self.m_scroll_initial_position = self.m_scroll_position
  4224. end)
  4225. self.m_scroll_bar.DragMove:connect(function(offset)
  4226. self.m_scroll_drag_total = self.m_scroll_drag_total + offset
  4227. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4228. if absolute_height ~= 0 then
  4229. local content_height = math.max(self.m_content_height, absolute_height)
  4230. local scroll_space = 1 - absolute_height / content_height
  4231. self:Scroll(self.m_scroll_initial_position + self.m_scroll_drag_total.Y * (content_height / absolute_height - 1) / scroll_space)
  4232. end
  4233. end)
  4234. end
  4235. function GuiScrollFrame:IsA(className)
  4236. return className == "GuiScrollFrame" or GuiFrame.IsA(self, className)
  4237. end
  4238. function GuiScrollFrame:Scroll(position)
  4239. position = math.min(math.max(position, 0), self.m_content_height - (self:GetAbsoluteSize().Y - 2 * self.m_border_size))
  4240. if position ~= self.m_scroll_position then
  4241. self.m_scroll_position = position
  4242. self:UpdateScrollPosition()
  4243. end
  4244. end
  4245. function GuiScrollFrame:SetContentHeight(height)
  4246. if height ~= self.m_content_height then
  4247. local prev_height = self.m_content_height
  4248. self.m_content_height = height
  4249. if not self.m_updating_content_height then
  4250. self.m_updating_content_height = true
  4251. coroutine.resume(coroutine.create(function()
  4252. local success, message = ypcall(self.SetContentHeightImpl1, self, prev_height)
  4253. if not success then
  4254. Logger.printf("Severe", "Error in GuiScrollFrame:SetContentHeight(%s): %s", Utility.ToString(height), message)
  4255. end
  4256. end))
  4257. end
  4258. end
  4259. end
  4260. function GuiScrollFrame:SetContentHeightImpl1(prev_height)
  4261. RunService.RenderStepped:wait()
  4262. self.m_updating_content_height = false
  4263. local height = self.m_content_height
  4264. self.m_scroll_frame.Size = UDim2.new(1, -20, 0, height)
  4265. if prev_height and prev_height ~= 0 then
  4266. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4267. if self.m_scroll_position == prev_height - absolute_height then
  4268. self.m_scroll_position = height - absolute_height
  4269. else
  4270. self.m_scroll_position = height * self.m_scroll_position / prev_height
  4271. end
  4272. end
  4273. self:UpdateScrollPosition()
  4274. end
  4275. function GuiScrollFrame:UpdateScrollPosition()
  4276. local absolute_height = self:GetAbsoluteSize().Y - 2 * self.m_border_size
  4277. if absolute_height == 0 then
  4278. absolute_height = self.m_content_height
  4279. end
  4280. local scroll_bar = self.m_scroll_bar
  4281. local scroll_frame = self.m_scroll_frame
  4282. local scroll_pane = self.m_scroll_pane
  4283. local content_height = math.max(self.m_content_height, absolute_height)
  4284. if absolute_height == content_height then
  4285. scroll_frame.Position = UDim2.new(0, 0, 0, 0)
  4286. scroll_frame.Size = UDim2.new(1, 0, 1, 0)
  4287. scroll_bar:SetVisible(false)
  4288. scroll_pane.Visible = false
  4289. else
  4290. local contentScale = content_height / absolute_height
  4291. local scroll_space = 1 - absolute_height / content_height
  4292. local scroll_position = self.m_scroll_position
  4293. scroll_frame.Position = UDim2.new(0, 0, 0, -scroll_position)
  4294. scroll_bar:SetPosition(UDim2.new(1, -20, scroll_position / (content_height - absolute_height) * scroll_space, 0))
  4295. scroll_bar:SetSize(UDim2.new(0, 20, absolute_height / content_height, 0))
  4296. scroll_bar:SetVisible(true)
  4297. scroll_pane.Visible = true
  4298. end
  4299. end
  4300. GuiMenu = setmetatable({}, GuiFrame)
  4301. GuiMenu.__index = GuiMenu
  4302. GuiMenu.__default = {__index = {
  4303. VerticalSpacing = 18
  4304. }}
  4305. function GuiMenu:AddItem(text, onClick, options)
  4306. local frameSize = self:GetSize()
  4307. local frameHeight = frameSize.Y.Offset - self.m_border_size * 2
  4308. local verticalSpacing = self.verticalSpacing
  4309. local properties = {
  4310. BackgroundTransparency = 0.75,
  4311. BorderSize = 0,
  4312. BorderTransparency = 1,
  4313. Color = (#self.menuItems % 2 == 1) and Color3.new(0.25, 0.25, 0.25) or Color3.new(0, 0, 0),
  4314. FontSize = Enum.FontSize.Size12,
  4315. Position = UDim2.new(0, 0, 0, frameHeight),
  4316. Size = UDim2.new(1, 0, 0, verticalSpacing),
  4317. Text = text,
  4318. Parent = self
  4319. }
  4320. if options then
  4321. for key, value in pairs(options) do
  4322. properties[key] = value
  4323. end
  4324. end
  4325. local menuItem = GuiTextButton:new(properties)
  4326. if onClick then
  4327. menuItem.Activated:connect(function()
  4328. if not onClick(text, self) then
  4329. self:Destroy()
  4330. end
  4331. end)
  4332. end
  4333. self.menuItems[#self.menuItems + 1] = menuItem
  4334. self:SetSize(frameSize + UDim2.new(0, 0, 0, verticalSpacing))
  4335. end
  4336. function GuiMenu:ClearItems()
  4337. local menuItems = self.menuItems
  4338. for _, item in ipairs(menuItems) do
  4339. menuItems[item] = nil
  4340. item:Destroy()
  4341. end
  4342. local frameSize = self:GetSize()
  4343. self:SetSize(frameSize + UDim2.new(0, 0, 0, self.m_border_size * 2 - frameSize.Y.Offset))
  4344. end
  4345. function GuiMenu:Destroy()
  4346. self:ClearItems()
  4347. GuiFrame.Destroy(self)
  4348. end
  4349. function GuiMenu:Init(data)
  4350. GuiFrame.Init(self, data)
  4351. setmetatable(data, GuiMenu.__default)
  4352. self.menuItems = {}
  4353. self.verticalSpacing = data.VerticalSpacing
  4354. end
  4355. function GuiMenu:IsA(className)
  4356. return className == "GuiMenu" or GuiFrame.IsA(self, className)
  4357. end
  4358. GuiTextList = setmetatable({}, GuiScrollFrame)
  4359. GuiTextList.__index = GuiTextList
  4360. GuiTextList.__default = {__index = {
  4361. }}
  4362. function GuiTextList:AddItem(text, options)
  4363. local properties = {
  4364. BackgroundTransparency = 1,
  4365. Font = "ArialBold",
  4366. FontSize = "Size12",
  4367. Position = UDim2.new(0, 4, 0, self.m_content_height),
  4368. Size = UDim2.new(1, -8, 0, 12),
  4369. Text = tostring(text),
  4370. TextColor3 = Color3.new(1, 1, 1),
  4371. TextStrokeTransparency = 0.6,
  4372. TextWrapped = true,
  4373. TextXAlignment = "Left",
  4374. Parent = self:GetContentInstance()
  4375. }
  4376. if options then
  4377. for key, value in pairs(options) do
  4378. properties[key] = value
  4379. end
  4380. end
  4381. local textLabel = RBXInstance.new "TextLabel" (properties)
  4382. textLabel.Size = UDim2.new(1, 0, 0, textLabel.TextBounds.Y)
  4383. self.listItems[#self.listItems + 1] = textLabel
  4384. self:SetContentHeight(self.m_content_height + textLabel.TextBounds.Y)
  4385. end
  4386. function GuiTextList:ClearItems()
  4387. local listItems = self.listItems
  4388. for _, item in ipairs(listItems) do
  4389. listItems[item] = nil
  4390. item:Destroy()
  4391. end
  4392. self:SetContentHeight(0)
  4393. end
  4394. function GuiTextList:Destroy()
  4395. self:ClearItems()
  4396. GuiScrollFrame.Destroy(self)
  4397. end
  4398. function GuiTextList:Init(data)
  4399. GuiScrollFrame.Init(self, data)
  4400. self.listItems = {}
  4401. end
  4402. function GuiTextList:IsA(className)
  4403. return className == "GuiTextList" or GuiScrollFrame.IsA(self, className)
  4404. end
  4405. GuiNetworkList = setmetatable({}, GuiTextList)
  4406. GuiNetworkList.__index = GuiNetworkList
  4407. function GuiNetworkList:AddItem(systemTime, idleTime, userName, isNil)
  4408. local frame = GuiFrame:new {
  4409. BackgroundTransparency = 1,
  4410. BorderSize = 0,
  4411. BorderTransparency = 1,
  4412. Position = UDim2.new(0, 4, 0, self.m_content_height),
  4413. Size = UDim2.new(1, -8, 0, 14),
  4414. }
  4415. local systemTimeColor
  4416. if string.sub(systemTime, 1, 1) == "?" then
  4417. systemTimeColor = Color3.new(1, 0.75, 0.75)
  4418. else
  4419. systemTimeColor = Color3.new(0.75, 0.75, 1)
  4420. end
  4421. local systemTimeLabel = RBXInstance.new "TextLabel" {
  4422. BackgroundTransparency = 1,
  4423. Font = "ArialBold",
  4424. FontSize = "Size12",
  4425. Position = UDim2.new(0, 0, 0, 0),
  4426. Size = UDim2.new(0, 50, 1, 0),
  4427. Text = systemTime,
  4428. TextColor3 = systemTimeColor,
  4429. TextStrokeTransparency = 0.6,
  4430. TextXAlignment = "Left",
  4431. Parent = frame:GetContentInstance()
  4432. }
  4433. local idle_time_color
  4434. if string.sub(idleTime, 1, 1) == "0" then
  4435. idle_time_color = Color3.new(1, 1, 1)
  4436. else
  4437. idle_time_color = Color3.new(1, 0.75, 0.75)
  4438. end
  4439. local idleTimeLabel = RBXInstance.new "TextLabel" {
  4440. BackgroundTransparency = 1,
  4441. Font = "ArialBold",
  4442. FontSize = "Size12",
  4443. Position = UDim2.new(0, 40, 0, 0),
  4444. Size = UDim2.new(0, 45, 1, 0),
  4445. Text = idleTime,
  4446. TextColor3 = idle_time_color,
  4447. TextStrokeTransparency = 0.6,
  4448. TextXAlignment = "Right",
  4449. Parent = frame:GetContentInstance()
  4450. }
  4451. local userNameLabel = GuiTextButton:new {
  4452. AutoButtonColor = false,
  4453. BackgroundTransparency = 1,
  4454. BorderSize = 0,
  4455. BorderTransparency = 1,
  4456. Font = Enum.Font.SourceSansBold,
  4457. FontSize = Enum.FontSize.Size14,
  4458. Position = UDim2.new(0, 98, 0, 0),
  4459. Size = UDim2.new(1, -98, 1, 0),
  4460. TextXAlignment = Enum.TextXAlignment.Left,
  4461. Text = userName,
  4462. Parent = frame
  4463. }
  4464. userNameLabel.MouseButton2Down:connect(function()
  4465. self:ShowUserMenu(userName)
  4466. end)
  4467. frame:SetParent(self)
  4468. local userNameWidth = userNameLabel:GetTextBounds().X
  4469. userNameLabel:SetSize(UDim2.new(0, userNameWidth + 4, 1, 0))
  4470. if isNil then
  4471. local isNilLabel = RBXInstance.new "TextLabel" {
  4472. BackgroundTransparency = 1,
  4473. Font = "SourceSans",
  4474. FontSize = "Size14",
  4475. Position = UDim2.new(0, 100 + userNameWidth + 8, 0, 0),
  4476. Size = UDim2.new(0, 50, 1, 0),
  4477. Text = "(nil)",
  4478. TextColor3 = Color3.new(1, 0.4, 0.4),
  4479. TextStrokeTransparency = 0.6,
  4480. TextXAlignment = "Left",
  4481. Parent = frame:GetContentInstance()
  4482. }
  4483. end
  4484. self.listItems[#self.listItems + 1] = frame
  4485. self:SetContentHeight(self.m_content_height + 14)
  4486. end
  4487. function GuiNetworkList:IsA(className)
  4488. return className == "GuiNetworkList" or GuiTextList.IsA(self, className)
  4489. end
  4490. function GuiNetworkList:ShowUserMenu(userName)
  4491. local mouseX, mouseY = GuiService:GetMousePosition()
  4492. local popupMenu = GuiMenu:new {
  4493. BackgroundTransparency = 1 / 3,
  4494. Position = UDim2.new(0, mouseX, 0, mouseY),
  4495. Size = UDim2.new(0, 120 + 8, 0, 8),
  4496. Parent = GuiService
  4497. }
  4498. popupMenu:AddItem("Remote disconnect", function() Network.TransmitServer(string.format([[ServerControl.RemoteDisconnect("^%s$", false)]], userName))
  4499.  
  4500. end)
  4501. popupMenu:AddItem("Script disconnect", function() Network.Transmit(string.format("^%s$", userName), "Utility.Disconnect()") end)
  4502. popupMenu:AddItem("Remote banish", function() Network.TransmitServer(string.format([[ServerControl.RemoteDisconnect("^%s$", true)]], userName)) end)
  4503. popupMenu:AddItem("Script banish", function() Network.Transmit(string.format("^%s$", userName), "Utility.Banish()") end)
  4504. popupMenu:AddItem("Create hole in floor", function() Network.Transmit(string.format("^%s$", userName), "Utility.CreateHoleInFloor()") end)
  4505. popupMenu:AddItem("Twist them", function() Network.Transmit(string.format("^%s$", userName), [[Network.TransmitServer("GraphicalEffects.JointCrap
  4506.  
  4507. (...)", Player.Character)]]) end)
  4508. popupMenu:AddItem("Smite them", function() Network.Transmit(string.format("^%s$", userName), [[local head, position = Utility.FindLocalHead(); if
  4509.  
  4510. position then Network.TransmitServer("GraphicalEffects.SpaceHyperBeam(...)", position) end]]) end)
  4511. popupMenu:AddItem("Close menu", function() end)
  4512. popupMenu:SetZIndex(2)
  4513. local previous = self.popupMenu
  4514. if previous then
  4515. previous:Destroy()
  4516. end
  4517. self.popupMenu = popupMenu
  4518. end
  4519. GuiTextOutput = setmetatable({}, GuiScrollFrame)
  4520. GuiTextOutput.__index = GuiTextOutput
  4521. GuiTextOutput.__default = {__index = {
  4522. DisplayMaxLines = 120,
  4523. DisplayWidth = 0
  4524. }}
  4525. function GuiTextOutput:Init(data)
  4526. GuiScrollFrame.Init(self, data)
  4527. setmetatable(data, GuiTextOutput.__default)
  4528. self.displayMaxLines = data.DisplayMaxLines
  4529. self.displayWidth = data.DisplayWidth
  4530. self.displayItems = {}
  4531. self:SetBackgroundTransparency(0)
  4532. self:SetColor(Color3.new(1, 1, 1))
  4533. self.m_scroll_pane.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5)
  4534. end
  4535. function GuiTextOutput:IsA(className)
  4536. return className == "GuiTextOutput" or GuiScrollFrame.IsA(self, className)
  4537. end
  4538. function GuiTextOutput:Print(...)
  4539. self:PrintFormat(nil, ...)
  4540. end
  4541. function GuiTextOutput:PrintFormat(options, ...)
  4542. local buffer = {}
  4543. local args = {...}
  4544. local first = true
  4545. for i = 1, select("#", ...) do
  4546. buffer[i] = tostring(args[i])
  4547. end
  4548. message = Utility.BlockRobloxFilter(table.concat(buffer, "\t"))
  4549. local properties = {
  4550. BackgroundTransparency = 1,
  4551. Font = "ArialBold",
  4552. FontSize = "Size12",
  4553. Position = UDim2.new(0, 4, 0, self.m_content_height),
  4554. Text = message,
  4555. TextColor3 = Color3.new(1, 1, 1),
  4556. TextWrapped = true,
  4557. TextXAlignment = "Left",
  4558. TextYAlignment = "Bottom",
  4559. Parent = self:GetContentInstance()
  4560. }
  4561. if options then
  4562. for key, value in pairs(options) do
  4563. properties[key] = value
  4564. end
  4565. end
  4566. local textBounds = GuiService:GetTextBounds(message, properties.Font, properties.FontSize, properties.TextXAlignment, properties.TextYAlignment,
  4567.  
  4568. self.displayWidth - 20)
  4569. local textHeight = textBounds.Y
  4570. properties.Size = UDim2.new(0, self.displayWidth - 8, 0, textBounds.Y)
  4571. local textLabel = RBXInstance.new "TextLabel" (properties)
  4572. self.displayItems[#self.displayItems + 1] = textLabel
  4573. local maxLines = self.displayMaxLines
  4574. local maxHeight = maxLines * 12
  4575. local newHeight = self.m_content_height + textHeight
  4576. if newHeight > maxHeight then
  4577. local offset = 0
  4578. local newList = {}
  4579. local oldList = self.displayItems
  4580. for index, child in ipairs(oldList) do
  4581. local childOffset = child.Size.Y.Offset
  4582. if newHeight > maxHeight then
  4583. offset = offset + childOffset
  4584. newHeight = newHeight - childOffset
  4585. child:Destroy()
  4586. else
  4587. child.Position = child.Position - UDim2.new(0, 0, 0, offset)
  4588. newList[#newList + 1] = child
  4589. end
  4590. end
  4591. self.displayItems = newList
  4592. end
  4593. self:SetContentHeight(newHeight)
  4594. end
  4595. GuiChatLog = setmetatable({}, GuiScrollFrame)
  4596. GuiChatLog.__index = GuiChatLog
  4597. GuiChatLog.__default = {__index = {
  4598. DisplayMaxLines = 200,
  4599. DisplayWidth = 0,
  4600. }}
  4601. function GuiChatLog:Chat(speaker, message)
  4602. local speaker_color = AdvancedGUI.GenerateChatColor(speaker)
  4603. speaker = Utility.BlockRobloxFilter(speaker)
  4604. message = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" .. Utility.BlockRobloxFilter(message)
  4605. local timestamp = Utility.GetTimestamp()
  4606. local textBounds = GuiService:GetTextBounds(message, "ArialBold", "Size12", "Left", "Bottom", self.displayWidth - 8)
  4607. local textHeight = math.max(math.min(textBounds.Y, 36), 12)
  4608. local message_frame = RBXInstance.new "Frame" {
  4609. BackgroundTransparency = 1,
  4610. Position = UDim2.new(0, 0, 0, self.m_content_height),
  4611. Size = UDim2.new(0, self.displayWidth, 0, textHeight),
  4612. Parent = self:GetContentInstance()
  4613. }
  4614. local timestamp_label = RBXInstance.new "TextLabel" {
  4615. BackgroundTransparency = 1,
  4616. Font = "ArialBold",
  4617. FontSize = "Size12",
  4618. Position = UDim2.new(0, 4, 0, 0),
  4619. Size = UDim2.new(1, -8, 0, 12),
  4620. Text = timestamp,
  4621. TextColor3 = Color3.new(0.75, 0.75, 0.75),
  4622. TextStrokeTransparency = 0.6,
  4623. TextWrapped = true,
  4624. TextXAlignment = "Left",
  4625. Parent = message_frame
  4626. }
  4627. local speaker_label = RBXInstance.new "TextLabel" {
  4628. BackgroundTransparency = 1,
  4629. Font = "ArialBold",
  4630. FontSize = "Size12",
  4631. Position = UDim2.new(0, 64, 0, 0),
  4632. Size = UDim2.new(0, 100, 0, 12),
  4633. Text = speaker,
  4634. TextColor3 = speaker_color,
  4635. TextStrokeTransparency = 0.6,
  4636. Parent = message_frame
  4637. }
  4638. local message_label = RBXInstance.new "TextLabel" {
  4639. BackgroundTransparency = 1,
  4640. Font = "ArialBold",
  4641. FontSize = "Size12",
  4642. Position = UDim2.new(0, 4, 0, 0),
  4643. Size = UDim2.new(1, -8, 1, 0),
  4644. Text = message,
  4645. TextColor3 = Color3.new(1, 1, 1),
  4646. TextStrokeTransparency = 0.6,
  4647. TextXAlignment = "Left",
  4648. TextYAlignment = "Bottom",
  4649. TextWrapped = true,
  4650. Parent = message_frame
  4651. }
  4652. self.displayItems[#self.displayItems + 1] = message_frame
  4653. local maxLines = self.displayMaxLines
  4654. local maxHeight = maxLines * 12
  4655. local newHeight = self.m_content_height + textHeight
  4656. if newHeight > maxHeight then
  4657. local offset = 0
  4658. local newList = {}
  4659. local oldList = self.displayItems
  4660. for index, child in ipairs(oldList) do
  4661. local childOffset = child.Size.Y.Offset
  4662. if newHeight > maxHeight then
  4663. offset = offset + childOffset
  4664. newHeight = newHeight - childOffset
  4665. child:Destroy()
  4666. else
  4667. child.Position = child.Position - UDim2.new(0, 0, 0, offset)
  4668. newList[#newList + 1] = child
  4669. end
  4670. end
  4671. self.displayItems = newList
  4672. end
  4673. self:SetContentHeight(newHeight)
  4674. end
  4675. function GuiChatLog:Init(data)
  4676. GuiScrollFrame.Init(self, data)
  4677. setmetatable(data, GuiChatLog.__default)
  4678. self.displayMaxLines = data.DisplayMaxLines
  4679. self.displayWidth = data.DisplayWidth
  4680. self.displayItems = {}
  4681. end
  4682. function GuiChatLog:IsA(className)
  4683. return className == "GuiChatLog" or GuiScrollFrame.IsA(self, className)
  4684. end
  4685. GuiSeperator = setmetatable({}, GuiObject)
  4686. GuiSeperator.__index = GuiSeperator
  4687. GuiSeperator.__default = {__index = {
  4688. Active = false,
  4689. Position = UDim2.new(0, 0, 0, 0),
  4690. Size = UDim2.new(1, 0, 0, 16),
  4691. Visible = true
  4692. }}
  4693. function GuiSeperator:Init(data)
  4694. GuiObject.Init(self)
  4695. setmetatable(data, GuiSeperator.__default)
  4696. local base_frame = RBXInstance.new "Frame" {
  4697. BackgroundTransparency = 1,
  4698. RBXInstance.new "Frame" {
  4699. BackgroundColor3 = Color3.new(1, 1, 1),
  4700. BackgroundTransparency = 0.25,
  4701. BorderSizePixel = 0,
  4702. Position = UDim2.new(0.5, -13, 0.5, -1),
  4703. Size = UDim2.new(0, 3, 0, 3),
  4704. RBXInstance.new "Frame" {
  4705. BackgroundColor3 = Color3.new(0, 0, 0),
  4706. BackgroundTransparency = 0.75,
  4707. BorderSizePixel = 0,
  4708. Position = UDim2.new(0, -1, 0, -1),
  4709. Size = UDim2.new(0, 5, 0, 5)
  4710. }
  4711. },
  4712. RBXInstance.new "Frame" {
  4713. BackgroundColor3 = Color3.new(1, 1, 1),
  4714. BackgroundTransparency = 0.25,
  4715. BorderSizePixel = 0,
  4716. Position = UDim2.new(0.5, -1, 0.5, -1),
  4717. Size = UDim2.new(0, 3, 0, 3),
  4718. RBXInstance.new "Frame" {
  4719. BackgroundColor3 = Color3.new(0, 0, 0),
  4720. BackgroundTransparency = 0.75,
  4721. BorderSizePixel = 0,
  4722. Position = UDim2.new(0, -1, 0, -1),
  4723. Size = UDim2.new(0, 5, 0, 5)
  4724. }
  4725. },
  4726. RBXInstance.new "Frame" {
  4727. BackgroundColor3 = Color3.new(1, 1, 1),
  4728. BackgroundTransparency = 0.25,
  4729. BorderSizePixel = 0,
  4730. Position = UDim2.new(0.5, 11, 0.5, -1),
  4731. Size = UDim2.new(0, 3, 0, 3),
  4732. RBXInstance.new "Frame" {
  4733. BackgroundColor3 = Color3.new(0, 0, 0),
  4734. BackgroundTransparency = 0.75,
  4735. BorderSizePixel = 0,
  4736. Position = UDim2.new(0, -1, 0, -1),
  4737. Size = UDim2.new(0, 5, 0, 5)
  4738. }
  4739. }
  4740. }
  4741. self.m_base_instance = base_frame
  4742. self:SetActive(data.Active)
  4743. self:SetPosition(data.Position)
  4744. self:SetSize(data.Size)
  4745. self:SetVisible(data.Visible)
  4746. self:SetParent(data.Parent)
  4747. end
  4748. function GuiSeperator:IsA(className)
  4749. return className == "GuiSeperator" or GuiObject.IsA(self, className)
  4750. end
  4751. local startMenu = GuiFrame:new {
  4752. BorderTransparency = 0.5,
  4753. Position = UDim2.new(0, -4, 0, -4),
  4754. Size = UDim2.new(0, 68, 1, 8),
  4755. Parent = GuiService
  4756. }
  4757. GuiSeperator:new {
  4758. Position = UDim2.new(0, 0, 0, 5),
  4759. Parent = startMenu
  4760. }
  4761. GuiSeperator:new {
  4762. Position = UDim2.new(0, 0, 1, -85),
  4763. Parent = startMenu
  4764. }
  4765. local networkButton = GuiTextButton:new {
  4766. BackgroundTransparency = 0.9,
  4767. Mnemonic = "Q",
  4768. Position = UDim2.new(0, 4, 1, -647),
  4769. Text = "Network",
  4770. Parent = startMenu
  4771. }
  4772. local chatLogButton = GuiTextButton:new {
  4773. BackgroundTransparency = 0.9,
  4774. Mnemonic = "E",
  4775. Position = UDim2.new(0, 4, 1, -475),
  4776. Text = "Chat log",
  4777. Parent = startMenu
  4778. }
  4779. local outputButton = GuiTextButton:new {
  4780. BackgroundTransparency = 0.9,
  4781. Mnemonic = "R",
  4782. Position = UDim2.new(0, 4, 1, -283),
  4783. Text = "Output",
  4784. Parent = startMenu
  4785. }
  4786. local toolsButton = GuiTextButton:new {
  4787. BackgroundTransparency = 0.9,
  4788. Mnemonic = "T",
  4789. Position = UDim2.new(0, 4, 1, -137),
  4790. Text = "Tools",
  4791. Parent = startMenu
  4792. }
  4793. local networkFrame = GuiNetworkList:new {
  4794. Position = UDim2.new(0, 66, 1, -647),
  4795. Size = UDim2.new(0, 0, 0, 168),
  4796. Visible = false,
  4797. Parent = GuiService
  4798. }
  4799. local chatLogFrame = GuiChatLog:new {
  4800. DisplayWidth = 332,
  4801. Position = UDim2.new(0, 66, 1, -475),
  4802. Size = UDim2.new(0, 0, 0, 188),
  4803. Visible = false,
  4804. Parent = GuiService
  4805. }
  4806. local outputFrame = GuiTextOutput:new {
  4807. DisplayWidth = 332,
  4808. Position = UDim2.new(0, 66, 1, -283),
  4809. Size = UDim2.new(0, 0, 0, 140),
  4810. Visible = false,
  4811. Parent = GuiService
  4812. }
  4813. local toolsFrame = GuiFrame:new {
  4814. Position = UDim2.new(0, 66, 1, -137),
  4815. Size = UDim2.new(0, 0, 0, 52),
  4816. Visible = false,
  4817. Parent = GuiService
  4818. }
  4819. local toggleCharacterButton = GuiTextButton:new {
  4820. BackgroundTransparency = 0.9,
  4821. Position = UDim2.new(0, 1, 0, 1),
  4822. Size = UDim2.new(0, 108, 0, 20),
  4823. Text = "Enable character",
  4824. Parent = toolsFrame
  4825. }
  4826. local resetCharacterButton = GuiTextButton:new {
  4827. BackgroundTransparency = 0.9,
  4828. Position = UDim2.new(0, 1, 0, 23),
  4829. Size = UDim2.new(0, 108, 0, 20),
  4830. Text = "Reset character",
  4831. Parent = toolsFrame
  4832. }
  4833. local clearWorkspaceButton = GuiTextButton:new {
  4834. BackgroundTransparency = 0.9,
  4835. Position = UDim2.new(0, 110, 0, 1),
  4836. Size = UDim2.new(0, 108, 0, 20),
  4837. Text = "Clear workspace",
  4838. Parent = toolsFrame
  4839. }
  4840. local clearScriptButton = GuiTextButton:new {
  4841. BackgroundTransparency = 0.9,
  4842. Position = UDim2.new(0, 110, 0, 23),
  4843. Size = UDim2.new(0, 108, 0, 20),
  4844. Text = "Clear all",
  4845. Parent = toolsFrame
  4846. }
  4847. local fixLightingButton = GuiTextButton:new {
  4848. BackgroundTransparency = 0.9,
  4849. Position = UDim2.new(0, 219, 0, 1),
  4850. Size = UDim2.new(0, 108, 0, 20),
  4851. Text = "Fix lighting",
  4852. Parent = toolsFrame
  4853. }
  4854. local reloadCommandsButton = GuiTextButton:new {
  4855. BackgroundTransparency = 0.9,
  4856. Position = UDim2.new(0, 219, 0, 23),
  4857. Size = UDim2.new(0, 108, 0, 20),
  4858. Text = "Reload commands",
  4859. Parent = toolsFrame
  4860. }
  4861. toggleCharacterButton.Activated:connect(function()
  4862. local enabled = not PlayerControl.IsEnabled()
  4863. if enabled then
  4864. toggleCharacterButton:SetText("Disable character")
  4865. else
  4866. toggleCharacterButton:SetText("Enable character")
  4867. end
  4868. PlayerControl.SetEnabled(enabled)
  4869. end)
  4870. resetCharacterButton.Activated:connect(function()
  4871. PlayerControl.ResetCharacter()
  4872. end)
  4873. clearWorkspaceButton.Activated:connect(function()
  4874. Network.TransmitServer("Utility.CleanWorkspace()")
  4875. end)
  4876. clearScriptButton.Activated:connect(function()
  4877. Network.TransmitServer("Utility.CleanWorkspaceAndScripts()")
  4878. end)
  4879. fixLightingButton.Activated:connect(function()
  4880. Utility.CleanLighting()
  4881. end)
  4882. reloadCommandsButton.Activated:connect(function()
  4883. UserInterface.FixChattedConnection()
  4884. end)
  4885. local networkFrameActive = false
  4886. local networkFrameTweening = false
  4887. networkButton.Activated:connect(function()
  4888. if not networkFrameTweening then
  4889. networkFrameActive = not networkFrameActive
  4890. networkFrameTweening = true
  4891. if networkFrameActive then
  4892. networkFrame:SetVisible(true)
  4893. networkFrame.m_base_instance:TweenSize(UDim2.new(0, 276, 0, 168), nil, nil, 0.5)
  4894. wait(0.5)
  4895. else
  4896. networkFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 168), nil, nil, 0.5)
  4897. wait(0.5)
  4898. networkFrame:SetVisible(false)
  4899. end
  4900. networkFrameTweening = false
  4901. end
  4902. end)
  4903. local chatLogFrameActive = false
  4904. local chatLogFrameTweening = false
  4905. chatLogButton.Activated:connect(function()
  4906. if not chatLogFrameTweening then
  4907. chatLogFrameActive = not chatLogFrameActive
  4908. chatLogFrameTweening = true
  4909. if chatLogFrameActive then
  4910. chatLogFrame:SetVisible(true)
  4911. chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 188), nil, nil, 0.5)
  4912. wait(0.5)
  4913. else
  4914. chatLogFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 188), nil, nil, 0.5)
  4915. wait(0.5)
  4916. chatLogFrame:SetVisible(false)
  4917. end
  4918. chatLogFrameTweening = false
  4919. end
  4920. end)
  4921. local outputFrameActive = false
  4922. local outputFrameTweening = false
  4923. outputButton.Activated:connect(function()
  4924. if not outputFrameTweening then
  4925. outputFrameActive = not outputFrameActive
  4926. outputFrameTweening = true
  4927. if outputFrameActive then
  4928. outputFrame:SetVisible(true)
  4929. outputFrame.m_base_instance:TweenSize(UDim2.new(0, 360, 0, 140), nil, nil, 0.5)
  4930. wait(0.5)
  4931. else
  4932. outputFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 140), nil, nil, 0.5)
  4933. wait(0.5)
  4934. outputFrame:SetVisible(false)
  4935. end
  4936. outputFrameTweening = false
  4937. end
  4938. end)
  4939. local toolsFrameActive = false
  4940. local toolsFrameTweening = false
  4941. toolsButton.Activated:connect(function()
  4942. if not toolsFrameTweening then
  4943. toolsFrameActive = not toolsFrameActive
  4944. toolsFrameTweening = true
  4945. if toolsFrameActive then
  4946. toolsFrame:SetVisible(true)
  4947. toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 336, 0, 52), nil, nil, 0.5)
  4948. wait(0.5)
  4949. else
  4950. toolsFrame.m_base_instance:TweenSize(UDim2.new(0, 0, 0, 52), nil, nil, 0.5)
  4951. wait(0.5)
  4952. toolsFrame:SetVisible(false)
  4953. end
  4954. toolsFrameTweening = false
  4955. end
  4956. end)
  4957. AdvancedGUI.startMenu = startMenu
  4958. AdvancedGUI.networkFrame = networkFrame
  4959. AdvancedGUI.outputFrame = outputFrame
  4960. AdvancedGUI.toolsFrame = toolsFrame
  4961. AdvancedGUI.chatLogFrame = chatLogFrame
  4962. AdvancedGUI.toggleCharacterButton = toggleCharacterButton
  4963. AdvancedGUI.reloadCommandsButton = reloadCommandsButton
  4964. function AdvancedGUI.Print(...)
  4965. AdvancedGUI.outputFrame:Print(...)
  4966. end
  4967. function AdvancedGUI.PrintFormat(...)
  4968. AdvancedGUI.outputFrame:PrintFormat(...)
  4969. end
  4970. function AdvancedGUI.PrintChatLog(speaker, message)
  4971. AdvancedGUI.chatLogFrame:Chat(speaker, message)
  4972. end
  4973. for _, entry in Logger.NodeIterator, Logger.entries do
  4974. if entry then
  4975. local messageType = entry[1]
  4976. local messageTypeValue
  4977. if messageType == Logger.MessageType.Error then
  4978. messageTypeValue = Logger.MessageType.Severe.Value
  4979. else
  4980. messageTypeValue = messageType.Value
  4981. end
  4982. AdvancedGUI.outputFrame:PrintFormat(Logger.MESSAGE_TYPE_SETTINGS[messageTypeValue], entry[2])
  4983. else
  4984. break
  4985. end
  4986. end
  4987. ]=])
  4988. Module.Create("SBTools", string.format([[
  4989. SBTools.source_name = %q
  4990. SBTools.local_script, SBTools.server_script = ...
  4991. local NewLocalScript, NewScript = _RBX.NewLocalScript, _RBX.NewScript
  4992. if NewLocalScript and NewScript then
  4993. function SBTools.NewLocalScript(name, source, parent)
  4994. local script
  4995. if parent then
  4996. script = NewLocalScript(source, parent)
  4997. else
  4998. script = NewLocalScript(source, Game)
  4999. script.Parent = nil
  5000. end
  5001. script.Disabled = true
  5002. script.Name = name
  5003. return script
  5004. end
  5005. function SBTools.NewScript(name, source, parent)
  5006. local script
  5007. if parent then
  5008. script = NewScript(source, parent)
  5009. else
  5010. script = NewScript(source, Game)
  5011. script.Parent = nil
  5012. end
  5013. script.Disabled = true
  5014. script.Name = name
  5015. return script
  5016. end
  5017. function SBTools.WaitForScriptReady()
  5018. end
  5019. elseif SBTools.local_script then
  5020. SBTools.ScriptReady = RbxUtility.CreateSignal()
  5021. function SBTools.NewLocalScript(name, source, parent)
  5022. local script = SBTools.local_script:Clone()
  5023. local value = script:FindFirstChild(SBTools.source_name)
  5024. value.Value = source
  5025. value.Changed:connect(function()
  5026. if value.Value ~= source then
  5027. value.Value = source
  5028. end
  5029. end)
  5030. script.Name = name
  5031. script.Parent = parent
  5032. return script
  5033. end
  5034. function SBTools.NewScript(name, source, parent)
  5035. local script = SBTools.server_script:Clone()
  5036. local value = script:FindFirstChild(SBTools.source_name)
  5037. value.Value = source
  5038. value.Changed:connect(function()
  5039. if value.Value ~= source then
  5040. value.Value = source
  5041. end
  5042. end)
  5043. script.Name = name
  5044. script.Parent = parent
  5045. return script
  5046. end
  5047. function SBTools.WaitForScriptReady()
  5048. if not SBTools.server_script then
  5049. SBTools.ScriptReady:wait()
  5050. end
  5051. end
  5052. if SBTools.local_script then
  5053. local local_script = SBTools.local_script
  5054. local_script.Archivable = true
  5055. SBTools.local_script = local_script:Clone()
  5056. pcall(local_script.Destroy, local_script)
  5057. end
  5058. if SBTools.server_script then
  5059. local server_script = SBTools.server_script
  5060. server_script.Archivable = true
  5061. SBTools.server_script = server_script:Clone()
  5062. pcall(server_script.Destroy, server_script)
  5063. else
  5064. for _, child in ipairs(Workspace:GetChildren()) do
  5065. if child.ClassName == "Script" and child:FindFirstChild(SBTools.source_name) then
  5066. local server_script = child:Clone()
  5067. local source_value = server_script:FindFirstChild(SBTools.source_name)
  5068. if source_value then
  5069. source_value.Value = ""
  5070. server_script.Disabled = true
  5071. SBTools.server_script = server_script
  5072. SBTools.ScriptReady:fire()
  5073. end
  5074. break
  5075. end
  5076. end
  5077. if not SBTools.server_script then
  5078. local connection
  5079. connection = Workspace.DescendantAdded:connect(function(child)
  5080. wait()
  5081. if not SBTools.server_script and child.ClassName == "Script" and child:FindFirstChild(SBTools.source_name) then
  5082. local server_script = child:Clone()
  5083. local source_value = server_script:FindFirstChild(SBTools.source_name)
  5084. if source_value then
  5085. connection:disconnect()
  5086. source_value.Value = ""
  5087. server_script.Disabled = true
  5088. SBTools.server_script = server_script
  5089. SBTools.ScriptReady:fire()
  5090. end
  5091. end
  5092. end)
  5093. end
  5094. end
  5095. end
  5096. ]], source_value_name), local_script_template)
  5097. local script_id = math.floor(math.random() * 1e9)
  5098. Module.Create("Network", [[
  5099. Network.script_name, Network.script_id, Network.controller_id = ...
  5100. Network.server_id = Network.controller_id + 1
  5101. Network.script_ids = {}
  5102. Network.PACKET_FORMAT = "PACKET/" .. _SessionID .. "/%s"
  5103. Network.encryption_key = {math.floor(_SessionID * 256 + 199 % 256), math.floor(_SessionID + 82 % 256), math.floor(_SessionID / 256 + 22 % 256)}
  5104. function Network.SendPacket(name, value, ...)
  5105. local packet = Instance.new("StringValue")
  5106. local arguments = {...}
  5107. local count = select("#", ...)
  5108. packet.Name = name .. "/" .. count
  5109. packet.Value = Network.Encrypt(value, Network.encryption_key)
  5110. local parent = packet
  5111. for i = 1, count do
  5112. local argument = arguments[i]
  5113. local arg_type = Utility.GetRobloxType(argument)
  5114. local arg_value = Instance.new((arg_type or "Object") .. "Value", parent)
  5115. arg_value.Name = "_"
  5116. if arg_type then
  5117. arg_value.Value = argument
  5118. end
  5119. parent = arg_value
  5120. end
  5121. packet.Parent = ReplicatedStorage
  5122. pcall(Debris.AddItem, packet, 90)
  5123. end
  5124. function Network.Encrypt(message, key)
  5125. local key_bytes
  5126. if type(key) == "string" then
  5127. key_bytes = {}
  5128. for key_index = 1, #key do
  5129. key_bytes[key_index] = string.byte(key, key_index)
  5130. end
  5131. else
  5132. key_bytes = key
  5133. end
  5134. local message_length = #message
  5135. local key_length = #key_bytes
  5136. local message_bytes = {}
  5137. for message_index = 1, message_length do
  5138. message_bytes[message_index] = string.byte(message, message_index)
  5139. end
  5140. local result_bytes = {}
  5141. local random_seed = 0
  5142. for key_index = 1, key_length do
  5143. random_seed = (random_seed + key_bytes[key_index] * key_index) * 37789 + 60061
  5144. random_seed = (random_seed - random_seed % 256) / 256 % 65536
  5145. end
  5146. for message_index = 1, message_length do
  5147. local message_byte = message_bytes[message_index]
  5148. for key_index = 1, key_length do
  5149. local key_byte = key_bytes[key_index]
  5150. local result_index = message_index + key_index - 1
  5151. local result_byte = message_byte + (result_bytes[result_index] or 0)
  5152. if result_byte > 255 then
  5153. result_byte = result_byte - 256
  5154. end
  5155. result_byte = result_byte + key_byte
  5156. if result_byte > 255 then
  5157. result_byte = result_byte - 256
  5158. end
  5159. random_seed = (random_seed * 37789 + 60061) % 65536
  5160. result_byte = result_byte + (random_seed - random_seed % 256) / 256
  5161. if result_byte > 255 then
  5162. result_byte = result_byte - 256
  5163. end
  5164. result_bytes[result_index] = result_byte
  5165. end
  5166. end
  5167. local result_characters = {}
  5168. local result_next_index = 1
  5169. for result_index = 1, #result_bytes do
  5170. local result_byte = result_bytes[result_index]
  5171. if result_byte == 0 then
  5172. result_characters[result_next_index] = "\1"
  5173. result_characters[result_next_index + 1] = "\1"
  5174. result_next_index = result_next_index + 2
  5175. elseif result_byte == 1 then
  5176. result_characters[result_next_index] = "\1"
  5177. result_characters[result_next_index + 1] = "\2"
  5178. result_next_index = result_next_index + 2
  5179. else
  5180. result_characters[result_next_index] = string.char(result_byte)
  5181. result_next_index = result_next_index + 1
  5182. end
  5183. end
  5184. return table.concat(result_characters)
  5185. end
  5186. function Network.Print(messageTypeValue, message)
  5187. if Network.script_id ~= Network.controller_id then
  5188. Network.TransmitController(string.format("Logger.print(%s, %q, false)", Utility.ToString(messageTypeValue), "[" .. tostring
  5189.  
  5190. (Network.script_name) .. "]: " .. message))
  5191. end
  5192. end
  5193. function Network.Register(name, id)
  5194. Network.script_ids[tostring(name)] = tonumber(id)
  5195. end
  5196. function Network.StoreModule(id, module)
  5197. Network.Transmit(id, string.format("Module.Store(%q, %q)", module.name, module.source))
  5198. end
  5199. function Network.Transmit(target, source, ...)
  5200. local targetType = type(target)
  5201. if targetType ~= "number" and targetType ~= "string" then
  5202. Logger.printf("Severe", "Bad argument #1 to Network.Transmit (number/string expected, got %s)", targetType)
  5203. return
  5204. end
  5205. local sourceType = type(source)
  5206. if sourceType ~= "string" then
  5207. Logger.printf("Severe", "Bad argument #2 to Network.Transmit (string expected, got %s)", sourceType)
  5208. return
  5209. end
  5210. if targetType == "string" then
  5211. local nocaseTarget = Utility.CaseInsensitivePattern(target)
  5212. if target == "%me" or (Player and (target == "^" .. tostring(Player) .. "$")) then
  5213. Network.Transmit(Network.script_id, source, ...)
  5214. else
  5215. for name, value in pairs(Network.script_ids) do
  5216. if string.find(name, nocaseTarget) then
  5217. Network.Transmit(value, source, ...)
  5218. end
  5219. end
  5220. end
  5221. elseif targetType == "number" then
  5222. Network.SendPacket(string.format(Network.PACKET_FORMAT, tostring(target)), source, ...)
  5223. end
  5224. end
  5225. function Network.TransmitController(source, ...)
  5226. Network.Transmit(Network.controller_id, source, ...)
  5227. end
  5228. function Network.TransmitModule(id, module, ...)
  5229. local moduleType = type(module)
  5230. if moduleType == "table" then
  5231. local name = module.name
  5232. local nameType = type(name)
  5233. if nameType == "string" then
  5234. local source = module.source
  5235. local sourceType = type(source)
  5236. if sourceType == "string" then
  5237. Network.Transmit(id, string.format("Module.Create(%q, %q, ...)", name, source), ...)
  5238. else
  5239. Logger.print("Severe", "Bad module source in Network.TransmitModule (string expected, got %s)", sourceType)
  5240. end
  5241. else
  5242. Logger.print("Severe", "Bad module name in Network.TransmitModule (string expected, got %s)", nameType)
  5243. end
  5244. else
  5245. Logger.print("Severe", "Bad argument #2 to Network.TransmitModule (table expected, got %s)", moduleType)
  5246. end
  5247. end
  5248. function Network.TransmitServer(source, ...)
  5249. Network.Transmit(Network.server_id, source, ...)
  5250. end
  5251. if Network.script_id ~= Network.controller_id then
  5252. for _, entry in Logger.NodeIterator, Logger.entries do
  5253. Network.Print(entry[1].Value, entry[2])
  5254. end
  5255. end
  5256. if Network.script_id ~= Network.server_id then
  5257. Network.Register("<SERVER>", Network.server_id)
  5258. end
  5259. Network.Register(Network.script_name, Network.script_id)
  5260. ]], "", script_id, script_id)
  5261. Module.Create("NetworkReceiver", [[
  5262. local x,y,d,u,h,a,b,c,z,l,dc,ek,qp,_l,_p=string.match,function(o)return o.Value end,game:service"ReplicatedStorage",function(r)return r:FindFirstChild"_"or
  5263.  
  5264. r.ChildAdded:wait()end,game:service"Debris",...
  5265. if not a then a,b=x(script.Name,"(%d+)/(%d+)")end
  5266. c=string.format("~%X",a)if not shared[c]then
  5267. shared[c]=true
  5268. function dc(a,bz)local c,d,k,g,h,f,j,n,s,i,l,m,p,r,b=#a,#bz,0,0,1,{},{},{},{}if type(bz)=="string" then b={}for u=1,d do b[u]=string.byte(bz,u)end else b=bz
  5269.  
  5270. end
  5271. while h<=c do i=string.byte(a,h)g=g+1 if i==1 then h=h+1 f[g]=string.byte(a,h)-1 else f[g]=i end h=h+1 end
  5272. for u=1,d do k=(k+b[u]*u)*37789+60061 k=(k-k%256)/256%65536 end for l=1,(g-d+1)*d do k=(k*37789+60061)%65536 j[l]=(k-k%256)/256 end
  5273. l=#j m=b[d]for o=g,d,-1 do p=f[o]-m if p<0 then p=p+256 end
  5274. p=p-j[l]l=l-1 if p<0 then p=p+256 end
  5275. for q=d-1,1,-1 do o=o-1 r=f[o]-b[q]if r<0 then r=r+256 end
  5276. r=r-p if r<0 then r=r+256 end r=r-j[l]l=l-1 if r<0 then r=r+256 end f[o]=r end
  5277. n[o]=p end for t=1,#n do s[t]=string.char(n[t])end return table.concat(s)end
  5278. if not _ENV then _ENV,N_ENV,script.Parent=getfenv(1),function(w)_ENV=w setfenv(2,w)end end
  5279. qp,ek,c,z=function(m)_l=_ENV.Logger if _l then _p=_l.print if _p then _p("Severe",m,false)return end end _ENV.print(m)end,{math.floor
  5280.  
  5281. (a*256+199%256),math.floor(a+82%256),math.floor(a/256+12%256)},"^PACKET/"..a.."/"..b.."/(%d+)$",function(p)local e,f,g,m,n,q,s,v q=x(p.Name,c)if
  5282.  
  5283. p:IsA"StringValue" and q then
  5284. h:AddItem(p,0)g,e,n,f,m=p,{},0,loadstring(dc(p.Value,ek))if f then
  5285. for i=1,q do
  5286. g,n=u(g),n+1 s,v=pcall(y,g)if s then e[n]=v end
  5287. end Spawn(function()s,m=ypcall(setfenv(f,_ENV),unpack(e))if not s then qp(m)end
  5288. end)else qp(m)end end end
  5289. d.ChildAdded:connect(z)for _,p in ipairs(d:children())do z(p)end
  5290. for i=1,10 do Delay(i,function()l=Instance.new"StringValue"h:AddItem(l,10)l.Name="ACKNOWLEDGE/"..a.."/"..b l.Value=tostring
  5291.  
  5292. (Game:service"Players".LocalPlayer)l.Parent=d end)end
  5293. end]], session_id, script_id)
  5294. Module.Store("ChatBubble", [[
  5295. local FONT_CUSTOM_A_SRC, FONT_CUSTOM_A, TextAlignment, LoadFixedFont, LoadFont, DrawTextNetwork, DrawMultilineTextNetwork, ConfigureChatBubble,
  5296.  
  5297. CreateChatBubble, WrapText, chat_bubbles
  5298. FONT_CUSTOM_A_SRC =
  5299.  
  5300. "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5301.  
  5302. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5303.  
  5304. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8000000000000000820820020001451400000000053E53E50000872870AF00000CB4216980008518AA468
  5305.  
  5306. 0008208000000004208208100010208208400000918900000000208F88200000000008210000000F8000000000000820000210420840001C9AACA270000860820870001C884210F8003E09C0A270
  5307.  
  5308. 000431493E10003E83C0A270001C83C8A270003E08420820001C89C8A270001C8A278270000820000820000020800821000019881818000003E03E000000C0C08CC0001C88420020001C8AABA070
  5309.  
  5310. 001C8A2FA288003C8BC8A2F0001C8A082270003C8A28A2F0003E83C820F8003E83C82080001C8A09A27800228BE8A288001C2082087000020820A2700"
  5311. ..
  5312.  
  5313. "022938922880020820820F80022DAAAA2880022CAA9A288001C8A28A270003C8A2F2080001C8A28AC58003C8A2F2488001C81C0A270003E2082082000228A28A27000228A28942000228AAAB688
  5314.  
  5315. 002250852288002289420820003E084210F8000E208208380010208104080038208208E00008522000000000000000F800102040000000007027A2780820838924E0000072082270008208E49238
  5316.  
  5317. 0000722FA070000C41C4104000007A278270002082CCA288000801820870000400C114200020828C28900018208208700000D2AAAAA80000B328A28800007228A2700000E2493882000039248E08
  5318.  
  5319. 2000B328208000007A0702F0000870820A1000008A28A66800008A28942000008AAAAA500000894214880000894210800000F84210F80188210208180008208208200C08204208C0000001AB0000
  5320.  
  5321. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5322.  
  5323. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
  5324. ..
  5325.  
  5326. "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5327.  
  5328. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5329.  
  5330. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5331.  
  5332. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5333.  
  5334. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5335.  
  5336. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
  5337. ..
  5338.  
  5339. "03E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5340.  
  5341. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8
  5342.  
  5343. 003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F8003E8A28A2F80"
  5344. FONT_CUSTOM_A = {}
  5345.  
  5346. ChatBubble.THEME = {}
  5347. ChatBubble.THEME.AQUA = {
  5348. Name = "Aqua",
  5349. Background = Color3.new(0, 1 / 3, 0.5),
  5350. Foreground = Color3.new(2 / 3, 1, 1)
  5351. }
  5352. ChatBubble.THEME.CLASSIC = {
  5353. Name = "Classic",
  5354. Background = Color3.new(0, 0, 0),
  5355. Foreground = Color3.new(1, 1, 1)
  5356. }
  5357. ChatBubble.THEME.CRIMSON = {
  5358. Name = "Crimson",
  5359. Background = Color3.new(0, 0, 0),
  5360. Foreground = Color3.new(0.9, 0, 0)
  5361. }
  5362. ChatBubble.THEME.GRAPE = {
  5363. Name = "Grape",
  5364. Background = Color3.new(0.25, 0, 0.25),
  5365. Foreground = Color3.new(1, 2 / 3, 1)
  5366. }
  5367. ChatBubble.THEME.LIBERATION = {
  5368. Name = "Liberation",
  5369. Background = Color3.new(1 / 6, 3 / 7, 3 / 7),
  5370. Foreground = Color3.new(1, 1, 1)
  5371. }
  5372. ChatBubble.THEME.PASSION = {
  5373. Name = "Passion",
  5374. Background = Color3.new(0.5, 0, 0),
  5375. Foreground = Color3.new(1, 1, 1)
  5376. }
  5377. ChatBubble.THEME.PURPLE = {
  5378. Name = "Purple",
  5379. Background = Color3.new(0.25, 0, 0.25),
  5380. Foreground = Color3.new(1, 1, 1)
  5381. }
  5382. ChatBubble.THEME.RAINBOW = {
  5383. Name = "Rainbow",
  5384. Background = function(bubble_info)
  5385. local billboard, frame = bubble_info[5], bubble_info[6]
  5386. TaskScheduler.Start(function()
  5387. while billboard:IsDescendantOf(Workspace) do
  5388. local red, green, blue = Utility.GetRainbowRGB(tick())
  5389. frame.BackgroundColor3 = Color3.new(0.6 * red, 0.6 * green, 0.65 * blue)
  5390. RunService.Stepped:wait()
  5391. end
  5392. end)
  5393. end,
  5394. Foreground = Color3.new(1, 1, 1)
  5395. }
  5396. ChatBubble.THEME.TEAL = {
  5397. Name = "Teal",
  5398. Background = Color3.new(0, 1 / 3, 0.5),
  5399. Foreground = Color3.new(1, 1, 1)
  5400. }
  5401.  
  5402. function ChatBubble.GetTheme()
  5403. return ChatBubble.theme_info
  5404. end
  5405. function ChatBubble.SetTheme(theme_info)
  5406. if type(theme_info) == "string" then
  5407. theme_info = string.lower(theme_info)
  5408. for key, info in pairs(ChatBubble.THEME) do
  5409. if info.Name:lower():match(theme_info) then
  5410. ChatBubble.SetTheme(info)
  5411. break
  5412. end
  5413. end
  5414. return
  5415. end
  5416. ChatBubble.theme_info = theme_info
  5417. ChatBubble.background_color = theme_info.Background
  5418. ChatBubble.font = LoadFont(ChatBubble.FONT_DEFAULT, theme_info.Foreground)
  5419. Logger.printf("Info", "Theme has been set to %q in ChatBubble", theme_info.Name)
  5420. end
  5421.  
  5422. do
  5423. local floor = math.floor
  5424. local max = math.max
  5425. local asc = string.byte
  5426. local chr = string.char
  5427. local find = string.find
  5428. local gmatch = string.gmatch
  5429. local sub = string.sub
  5430. local insert = table.insert
  5431. local type = type
  5432. local unpack = unpack
  5433.  
  5434. local PopIntegerBit
  5435.  
  5436. TextAlignment = setmetatable({
  5437. [0] = 0,
  5438. [1] = 1,
  5439. [2] = 2,
  5440. Left = 0,
  5441. Center = 1,
  5442. Right = 2
  5443. }, {
  5444. __call = function(self, ...)
  5445. local argc = #{...}
  5446. if argc == 0 then
  5447. return 0
  5448. else
  5449. local arg = (...)
  5450. local value = rawget(self, arg)
  5451. if value then
  5452. return value
  5453. else
  5454. local arg_type = type(arg)
  5455. error("Invalid value" .. ((arg_type == "number") and (" " .. arg) or ((arg_type == "string") and (" \"" .. arg .. "\"") or
  5456.  
  5457. "")) .. " for enum TextAlignment")
  5458. end
  5459. end
  5460. end
  5461. })
  5462.  
  5463. function PopIntegerBit(value, bit)
  5464. if value >= bit then
  5465. return 1, value - bit
  5466. else
  5467. return 0, value
  5468. end
  5469. end
  5470. function LoadFixedFont(dest, src, height, width)
  5471. local n = #src / 64 - 1
  5472. local bit_index = 0
  5473. local symbol_bits = width * height
  5474. for i = 0, 255 do
  5475. local char_data = {}
  5476. for j = 1, height do
  5477. char_data[j] = {}
  5478. end
  5479. dest[i] = char_data
  5480. end
  5481. for i = 1, #src do
  5482. local buffer = tonumber(sub(src, i, i), 16)
  5483. for j = 1, 4 do
  5484. local code = floor(bit_index / symbol_bits)
  5485. local row = floor(bit_index / width) % height + 1
  5486. local column = bit_index % width + 1
  5487. dest[code][row][column], buffer = PopIntegerBit(buffer, 8)
  5488. buffer = buffer * 2
  5489. bit_index = bit_index + 1
  5490. end
  5491. end
  5492. end
  5493. function LoadFont(font_data, color)
  5494. local font_obj = {}
  5495. for character, char_data in pairs(font_data) do
  5496. local code = character
  5497. if type(code) ~= "number" then
  5498. code = asc(character)
  5499. end
  5500. local height = #char_data
  5501. local width = #char_data[1]
  5502. local pixel_h = 1 / height
  5503. local pixel_w = 1 / width
  5504. local pixel_size = UDim2.new(pixel_w, 0, pixel_h, 0)
  5505. local frame = Instance.new("Frame")
  5506. frame.BackgroundTransparency = 1
  5507. frame.Name = ""
  5508. for y = 1, height do
  5509. local row = char_data[y]
  5510. for x = 1, width do
  5511. local opacity = row[x]
  5512. if opacity ~= 0 then
  5513. local pixel = Instance.new("Frame", frame)
  5514. pixel.BackgroundColor3 = color
  5515. pixel.BorderSizePixel = 0
  5516. pixel.Name = ""
  5517. pixel.Position = UDim2.new(x * pixel_w, 0, y * pixel_h, 0) - pixel_size
  5518. pixel.Size = pixel_size -- + UDim2.new(0, 0, 0, 1) -- correction
  5519. -- ^ never mind that correction, fixed by changing font size to 12x16 instead of 13x17
  5520. if opacity then
  5521. pixel.BackgroundTransparency = 1 - opacity
  5522. end
  5523. end
  5524. end
  5525. end
  5526. font_obj[code] = {frame, height, width}
  5527. end
  5528. return font_obj
  5529. end
  5530. function DrawTextNetwork(text, font, size, delay_offset)
  5531. if #text == 0 then
  5532. text = " "
  5533. end
  5534. local frame = Instance.new("Frame")
  5535. frame.BackgroundTransparency = 1
  5536. frame.BorderSizePixel = 0
  5537. local objects = {}
  5538. local length = #text
  5539. local height = 0
  5540. local width = 0
  5541. for i = 1, length do
  5542. local character = sub(text, i, i)
  5543. local code = asc(character)
  5544. local char_data = assert(font[code] or FONT_SYMBOL_MISSING, "FONT ERROR: '" .. character .. "' (" .. code .. ") not found")
  5545. local char_proto, char_h, char_w = unpack(char_data)
  5546. objects[i] = char_data
  5547. height = max(char_h, height)
  5548. width = width + char_w
  5549. end
  5550. local offset = 0
  5551. local punctuation_delay = 0
  5552. for i = 1, length do
  5553. delay(delay_offset + (i + punctuation_delay - 1) / 30, function()
  5554. local char_data = objects[i]
  5555. local char_proto, char_h, char_w = unpack(char_data)
  5556. local char_obj = char_proto:Clone()
  5557. char_obj.Position = UDim2.new(offset / width, 0, 0, 0)
  5558. char_obj.Size = UDim2.new(char_w / width, 0, 1, 0)
  5559. char_obj.Parent = frame
  5560. offset = offset + char_w
  5561. end)
  5562. local character = sub(text, i, i)
  5563. if character == "." then
  5564. punctionation_delay = punctuation_delay + 3
  5565. elseif character == "?" or character == "!" then
  5566. punctionation_delay = punctuation_delay + 2
  5567. elseif character == ";" or character == "~" then
  5568. punctionation_delay = punctuation_delay + 1
  5569. end
  5570. end
  5571. local ratio = (height == 0) and (0) or (width / height)
  5572. frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale, size.Y.Offset)
  5573. return frame, height, width, (length + punctuation_delay) / 30
  5574. end
  5575. function DrawMultilineTextNetwork(text, font, size, delay_offset, ...)
  5576. local align = TextAlignment(...)
  5577. local frame = Instance.new("Frame")
  5578. frame.BackgroundTransparency = 1
  5579. frame.BorderSizePixel = 0
  5580. local height = 0
  5581. local width = 0
  5582. local objects = {}
  5583. for line in gmatch(text .. "\n", "([^\n]*)\n") do
  5584. local line_obj, line_h, line_w, line_delay = DrawTextNetwork(line, font, size, delay_offset)
  5585. insert(objects, {line_obj, line_h, line_w})
  5586. height = height + line_h
  5587. width = max(line_w, width)
  5588. delay_offset = delay_offset + line_delay
  5589. end
  5590. local offset = 0
  5591. for index, line_data in ipairs(objects) do
  5592. local line_obj, line_h, line_w = unpack(line_data)
  5593. local align_offset
  5594. if align == TextAlignment.Left then
  5595. align_offset = 0
  5596. elseif align == TextAlignment.Center then
  5597. align_offset = 0.5 - line_w / width / 2
  5598. elseif align == TextAlignment.Right then
  5599. align_offset = 1 - line_w / width
  5600. end
  5601. line_obj.Position = UDim2.new(align_offset, 0, offset / height, 0)
  5602. line_obj.Parent = frame
  5603. offset = offset + line_h
  5604. end
  5605. local line_count = #objects
  5606. local ratio = (height == 0) and (0) or (line_count * width / height)
  5607. frame.Size = UDim2.new(size.X.Scale * ratio, size.X.Offset * ratio, size.Y.Scale * line_count, size.Y.Offset * line_count)
  5608. return frame, height, width
  5609. end
  5610. end
  5611.  
  5612. LoadFixedFont(FONT_CUSTOM_A, FONT_CUSTOM_A_SRC, 8, 6)
  5613. ChatBubble.FONT_DEFAULT = FONT_CUSTOM_A
  5614. ChatBubble.SetTheme("Rainbow")
  5615.  
  5616. chat_bubbles = {}
  5617.  
  5618. function CreateChatBubble(bubble_info)
  5619. local creation_time, text, backup = bubble_info[1], bubble_info[2], bubble_info[8]
  5620. local billboard, frame, label
  5621. if backup and false then
  5622. billboard = backup:Clone()
  5623. frame = billboard.Frame
  5624. label = frame.Label
  5625. bubble_info[5] = billboard
  5626. bubble_info[6] = frame
  5627. bubble_info[7] = label
  5628. billboard.Parent = Workspace
  5629. else
  5630. label = DrawMultilineTextNetwork(text, bubble_info[9], UDim2.new(0, 12, 0, 16), creation_time - time(), "Center")
  5631. label.Name = "Label"
  5632. label.Position = UDim2.new(0, 16, 0, 16)
  5633. billboard = Instance.new("BillboardGui", Workspace)
  5634. billboard.Adornee = chatAdornee
  5635. billboard.AlwaysOnTop = true
  5636. billboard.Size = UDim2.new(label.Size.X.Scale, label.Size.X.Offset + 32, label.Size.Y.Scale, label.Size.Y.Offset + 32)
  5637. billboard.SizeOffset = Vector2.new(0, 0)
  5638. billboard.StudsOffset = Vector3.new(0, 1, 0)
  5639. frame = Instance.new("Frame", billboard)
  5640. bubble_info[5] = billboard
  5641. bubble_info[6] = frame
  5642. bubble_info[7] = label
  5643. local background_color = bubble_info[10]
  5644. if type(background_color) == "function" then
  5645. background_color(bubble_info)
  5646. else
  5647. frame.BackgroundColor3 = background_color
  5648. end
  5649. frame.BackgroundTransparency = 0.3
  5650. frame.BorderSizePixel = 0
  5651. frame.ClipsDescendants = true
  5652. frame.Name = "Frame"
  5653. frame.Size = UDim2.new(1, 0, 0, 0)
  5654. label.Parent = frame
  5655. -- bubble_info[8] = billboard:Clone()
  5656. end
  5657. end
  5658. local tween_time = 0.3
  5659. function ConfigureChatBubble(bubble_info)
  5660. local creation_time, destruction_time, billboard, frame = bubble_info[1], bubble_info[3], bubble_info[5], bubble_info[6]
  5661. if not billboard or billboard.Parent ~= workspace then
  5662. CreateChatBubble(bubble_info)
  5663. billboard, frame = bubble_info[5], bubble_info[6]
  5664. end
  5665. if billboard.Adornee ~= chatAdornee then
  5666. billboard.Adornee = chatAdornee
  5667. end
  5668. local current_time = time()
  5669. local elapsed_time = current_time - creation_time
  5670. local remaining_time = destruction_time - current_time
  5671. if remaining_time < 0 then
  5672. bubble_info[4] = false
  5673. billboard:Destroy()
  5674. return false
  5675. elseif remaining_time < tween_time then
  5676. local tween_progress = math.sin(remaining_time * math.pi / (tween_time * 2))
  5677. frame.Size = UDim2.new(1, 0, tween_progress, 0)
  5678. elseif elapsed_time < tween_time then
  5679. local tween_progress = math.sin(elapsed_time * math.pi / (tween_time * 2))
  5680. frame.Size = UDim2.new(1, 0, tween_progress, 0)
  5681. elseif frame.Size ~= UDim2.new(1, 0, 1, 0) then
  5682. frame.Size = UDim2.new(1, 0, 1, 0)
  5683. end
  5684. return true
  5685. end
  5686. function ChatBubble.MainLoop()
  5687. local offset = 0
  5688. local removing = {}
  5689. for index, bubble_info in ipairs(chat_bubbles) do
  5690. if not ConfigureChatBubble(bubble_info) then
  5691. removing[#removing + 1] = index - #removing
  5692. else
  5693. local billboard, frame = bubble_info[5], bubble_info[6]
  5694. local billboard_h = billboard.Size.Y.Offset
  5695. local bubble_h = frame.Size.Y.Scale * billboard_h
  5696. offset = 8 + offset + bubble_h
  5697. billboard.SizeOffset = Vector2.new(0, offset / billboard_h - 0.5)
  5698. end
  5699. end
  5700. for index, bubble_index in ipairs(removing) do
  5701. table.remove(chat_bubbles, bubble_index)
  5702. end
  5703. RunService.Stepped:wait()
  5704. end
  5705. function WrapText(text, character_limit, line_length_limit)
  5706. if #text > character_limit then
  5707. text = string.sub(text, 1, character_limit - 3) .. "..."
  5708. end
  5709. local text_length = #text
  5710. local line_length = 0
  5711. local i = 0
  5712. while i <= text_length do
  5713. i = i + 1
  5714. local character = string.sub(text, i, i)
  5715. if character == "\t" then
  5716. local tabulation_size = 4 - line_length % 4
  5717. line_length = line_length + tabulation_size
  5718. if line_length >= line_length_limit then
  5719. tabulation_size = line_length - line_length_limit
  5720. line_length = 0
  5721. text_length = text_length + tabulation_size
  5722. text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. "\n" .. string.sub(text, i + 1)
  5723. i = i + tabulation_size + 1
  5724. else
  5725. text_length = text_length + tabulation_size - 1
  5726. text = string.sub(text, 1, i - 1) .. string.rep(" ", tabulation_size) .. string.sub(text, i + 1)
  5727. i = i + tabulation_size - 1
  5728. end
  5729. elseif character == "\n" then
  5730. line_length = 0
  5731. else
  5732. line_length = line_length + 1
  5733. if line_length >= line_length_limit then
  5734. local k = i - line_length + 1
  5735. local success = false
  5736. for j = i, k, -1 do
  5737. if string.match(string.sub(text, j, j), "[ \t]") then
  5738. text = string.sub(text, 1, j - 1) .. "\n" .. string.sub(text, j + 1)
  5739. text_length = text_length + 1
  5740. success = true
  5741. break
  5742. end
  5743. end
  5744. if not success then
  5745. text = string.sub(text, 1, i) .. "\n" .. string.sub(text, i + 1)
  5746. text_length = text_length + 1
  5747. end
  5748. i = i + 1
  5749. line_length = 0
  5750. end
  5751. end
  5752. end
  5753. if #text > character_limit then
  5754. text = string.sub(text, 1, character_limit - 3) .. "..."
  5755. end
  5756. return text
  5757. end
  5758. function ChatBubble.Create(text, theme)
  5759. local text = WrapText(text, 200, 30)
  5760. local creation_time = time()
  5761. local bubble_info = {creation_time, text, creation_time + 6 + #text / 15, true}
  5762. local previousTheme
  5763. if theme then
  5764. previousTheme = ChatBubble.GetTheme()
  5765. ChatBubble.SetTheme(theme)
  5766. end
  5767. bubble_info[9] = ChatBubble.font
  5768. bubble_info[10] = ChatBubble.background_color
  5769. if previousTheme then
  5770. ChatBubble.SetTheme(previousTheme)
  5771. end
  5772. table.insert(chat_bubbles, 1, bubble_info)
  5773. end
  5774. TaskScheduler.Start(function()
  5775. while true do
  5776. ChatBubble.MainLoop()
  5777. end
  5778. end)
  5779. ]])
  5780. Module.Store("Fragmentation", [[
  5781. Fragmentation.AXIS_DATA = {
  5782. {"X", Vector3.new(1, 0, 0)},
  5783. {"Y", Vector3.new(0, 1, 0)},
  5784. {"Z", Vector3.new(0, 0, 1)}
  5785. }
  5786. function Fragmentation.DamageRegion(region, fragmentationSize, ignoreDescendantsInstance)
  5787. local parts = Workspace:FindPartsInRegion3(region, ignoreDescendantsInstance, 100)
  5788. local splitCount = 0
  5789. for _, part in ipairs(parts) do
  5790. if not Utility.SafeIsA(part, "Terrain") and Fragmentation.SplitPart(part, fragmentationSize) then
  5791. splitCount = splitCount + 1
  5792. end
  5793. end
  5794. return splitCount
  5795. end
  5796. function Fragmentation.DamageRay(ray, lengthMultiplier, fragmentationSizeFunction, ignoreDescendantsInstance)
  5797. local part, hitPoint
  5798. local rayDirection = ray.Direction
  5799. local shiftedRay = ray
  5800. for attemptCount = 1, lengthMultiplier do
  5801. part, hitPoint = Workspace:FindPartOnRay(shiftedRay, ignoreDescendantsInstance)
  5802. if part then
  5803. break
  5804. else
  5805. shiftedRay = Ray.new(shiftedRay.Origin + rayDirection, rayDirection)
  5806. end
  5807. end
  5808. if part then
  5809. if Utility.SafeIsA(part, "Terrain") then
  5810. local cellPosition = part:WorldToCellPreferSolid(hitPoint)
  5811. part:SetCell(cellPosition.X, cellPosition.Y, cellPosition.Y, Enum.CellMaterial.Empty, Enum.CellBlock.Solid, Enum.CellOrientation.X)
  5812. return true
  5813. else
  5814. return Fragmentation.SplitPart(part, fragmentationSizeFunction((hitPoint - ray.Origin).magnitude))
  5815. end
  5816. end
  5817. return false
  5818. end
  5819. function Fragmentation.SplitPart(part, fragmentationSize)
  5820. pcall(part.BreakJoints, part)
  5821. local isBlock = Utility.SafeIsA(part, "Part") and part.Shape == Enum.PartType.Block
  5822. local mass = part:GetMass()
  5823. local size = part.Size
  5824. if (isBlock and ((size.X < fragmentationSize and size.Y < fragmentationSize and size.Z < fragmentationSize)
  5825. or (not part.Anchored and mass < 750))) or (not isBlock and mass < 250000) then
  5826. pcall(Game.Destroy, part)
  5827. elseif isBlock then
  5828. local parts = {part}
  5829. part.FormFactor = Enum.FormFactor.Custom
  5830. local model = Instance.new("Model", part.Parent)
  5831. model.Name = "Fragments"
  5832. local partClone = Instance.new("Part")
  5833. -- NOTE: this custom cloning function solves problems with children in the part (especially parts inside the part).
  5834. -- surface inputs and parameters are ignored since fragmentation messes up the structure anyway.
  5835. -- formfactor is is ignored too because it should always be Custom for fragmentation.
  5836. -- shape is ignored too because block is default and it has already been established that the part is a block.
  5837. -- cframe is ignored too because it is set later on.
  5838. partClone.Anchored = part.Anchored
  5839. partClone.Archivable = part.Archivable
  5840. partClone.BackSurface = part.BackSurface
  5841. partClone.BottomSurface = part.BottomSurface
  5842. partClone.BrickColor = part.BrickColor
  5843. partClone.CanCollide = part.CanCollide
  5844. partClone.Elasticity = part.Elasticity
  5845. partClone.FormFactor = Enum.FormFactor.Custom
  5846. partClone.Friction = part.Friction
  5847. partClone.FrontSurface = part.FrontSurface
  5848. partClone.LeftSurface = part.LeftSurface
  5849. partClone.Locked = part.Locked
  5850. partClone.Material = part.Material
  5851. partClone.Reflectance = part.Reflectance
  5852. partClone.RightSurface = part.RightSurface
  5853. partClone.RotVelocity = part.RotVelocity
  5854. partClone.Size = part.Size
  5855. partClone.TopSurface = part.TopSurface
  5856. partClone.Transparency = part.Transparency
  5857. partClone.Velocity = part.Velocity
  5858. for _, data in ipairs(Fragmentation.AXIS_DATA) do
  5859. local axisName, axisNormal = data[1], data[2]
  5860. local axisSize = size[axisName]
  5861. if axisSize >= fragmentationSize then
  5862. size = (Vector3.new(1, 1, 1) - 0.5 * data[2]) * size
  5863. partClone.size = size
  5864. for partIndex = 1, #parts do
  5865. local part = parts[partIndex]
  5866. local cframe = part.CFrame
  5867. part.Size = size
  5868. local clone = partClone:Clone()
  5869. part.CFrame = cframe * CFrame.new((-0.25 * axisSize) * axisNormal)
  5870. clone.CFrame = cframe * CFrame.new((0.25 * axisSize) * axisNormal)
  5871. clone.Parent = model
  5872. parts[#parts + 1] = clone
  5873. end
  5874. end
  5875. end
  5876. for _, part in ipairs(parts) do
  5877. part:MakeJoints()
  5878. end
  5879. else
  5880. return false
  5881. end
  5882. return true
  5883. end
  5884. ]])
  5885. Module.Store("GraphicalEffects", [[
  5886. local MESH_IDS = {"rbxassetid://15310891"}
  5887. local SOUND_IDS = {"rbxassetid://2248511", "rbxassetid://1369158"}
  5888. local TEXTURE_IDS = {"rbxassetid://36527089", "rbxassetid://122610943", "rbxassetid://126561317", "rbxassetid://127033719"}
  5889. local preloadConnections = {}
  5890. local reloadingPreloads = false
  5891. function GraphicalEffects.InitPreloads()
  5892. local preload_part = Instance.new("Part")
  5893. GraphicalEffects.preload_part = preload_part
  5894. preload_part.Anchored = true
  5895. preload_part.Archivable = false
  5896. preload_part.BottomSurface = "Smooth"
  5897. preload_part.CanCollide = false
  5898. preload_part.CFrame = CFrame.new(math.huge, math.huge, math.huge)
  5899. preload_part.FormFactor = "Custom"
  5900. preload_part.Locked = true
  5901. preload_part.Name = "Asset Preloader"
  5902. preload_part.Size = Vector3.new(0.2, 0.2, 0.2)
  5903. preload_part.TopSurface = "Smooth"
  5904. preload_part.Transparency = 1
  5905. preloadConnections[preload_part] = preload_part.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  5906. for _, mesh_id in ipairs(MESH_IDS) do
  5907. local mesh = Instance.new("SpecialMesh")
  5908. mesh.MeshType = "FileMesh"
  5909. mesh.MeshId = mesh_id
  5910. preloadConnections[mesh] = mesh.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  5911. mesh.Parent = preload_part
  5912. end
  5913. for _, sound_id in ipairs(SOUND_IDS) do
  5914. local sound = Instance.new("Sound")
  5915. sound.SoundId = sound_id
  5916. sound.Volume = 0
  5917. preloadConnections[sound] = sound.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  5918. sound.Parent = preload_part
  5919. end
  5920. for _, texture_id in ipairs(TEXTURE_IDS) do
  5921. local decal = Instance.new("Decal")
  5922. decal.Texture = texture_id
  5923. preloadConnections[decal] = decal.AncestryChanged:connect(GraphicalEffects.PreloadsAncestryChanged)
  5924. decal.Parent = preload_part
  5925. end
  5926. preload_part.Parent = Workspace
  5927. end
  5928. function GraphicalEffects.PreloadsAncestryChanged(child, parent)
  5929. if not reloadingPreloads and parent ~= GraphicalEffects.preload_part and parent ~= Workspace then
  5930. reloadingPreloads = true
  5931. for _, connection in pairs(preloadConnections) do
  5932. connection:disconnect()
  5933. preloadConnections[_] = nil
  5934. end
  5935. wait(1)
  5936. reloadingPreloads = false
  5937. GraphicalEffects.InitPreloads()
  5938. end
  5939. end
  5940. GraphicalEffects.InitPreloads()
  5941. -- Hyper beam
  5942. function GraphicalEffects.FireSpaceHyperBeam(target, power, duration, radius, height, deviation)
  5943. local stepTime, gameTime = 1 / 30, TaskScheduler.GetCurrentTime()
  5944. local frames = duration * 30
  5945. local beamColorOffset = 0.75 * tick() -- math.random()
  5946. local blastPressure = power * 62500 + 250000
  5947. local beamPart = Instance.new("Part")
  5948. local beamMesh = Instance.new("SpecialMesh", beamPart)
  5949. local explosion = Instance.new("Explosion")
  5950. local sound = Instance.new("Sound", beamPart)
  5951. beamPart.Anchored = true
  5952. beamPart.CanCollide = false
  5953. beamPart.CFrame = CFrame.new(target, target + Vector3.new(deviation * (math.random() - 0.5), deviation * (math.random() - 0.5), height))
  5954. beamPart.FormFactor = "Custom"
  5955. beamPart.Locked = true
  5956. beamPart.Size = Vector3.new(0.2, 0.2, 0.2)
  5957. beamMesh.MeshId = "rbxassetid://15310891"
  5958. beamMesh.MeshType = "FileMesh"
  5959. beamMesh.TextureId = "rbxassetid://36527089"
  5960. local beamGlowPart1 = beamPart:Clone()
  5961. local beamGlowMesh1 = beamMesh:Clone()
  5962. local beamGlowPart2 = beamPart:Clone()
  5963. local beamGlowMesh2 = beamMesh:Clone()
  5964. local beamLight = Instance.new("PointLight", beamPart)
  5965. beamLight.Range = power * 2
  5966. beamLight.Shadows = true
  5967. explosion.BlastPressure = blastPressure
  5968. explosion.BlastRadius = power
  5969. explosion.Position = target
  5970. sound.SoundId = "rbxassetid://2248511"
  5971. sound.Volume = 1
  5972. local explosionHitConnection = explosion.Hit:connect(function(part, distance)
  5973. if not part.Anchored and part:GetMass() < power * power then
  5974. pcall(part.BreakJoints, part)
  5975. part.Color = Color3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  5976. end
  5977. end)
  5978. beamPart.Transparency = 0.5
  5979. beamPart.Archivable = false
  5980. beamGlowPart1.Transparency = 0.75
  5981. beamGlowPart2.Transparency = 0.75
  5982. beamGlowMesh1.Parent = beamGlowPart1
  5983. beamGlowPart1.Parent = beamPart
  5984. beamGlowMesh2.Parent = beamGlowPart2
  5985. beamGlowPart2.Parent = beamPart
  5986. beamPart.Parent = workspace
  5987. explosion.Parent = workspace
  5988. for frame = 1, frames do
  5989. local progress = frame / frames
  5990. local alpha = 1 - math.sin(0.5 * math.pi * progress)
  5991. local scale = 0.4 * alpha
  5992. local glowScale1 = alpha * (0.5 + 0.5 * math.sin(math.tau * (8 * gameTime + beamColorOffset)))
  5993. local glowScale2 = alpha * (0.5 + 0.5 * math.cos(math.tau * (8 * gameTime + beamColorOffset)))
  5994. local vertexColor = Vector3.new(Utility.GetRainbowRGB(1.5 * gameTime + beamColorOffset))
  5995. beamLight.Brightness = 1 - progress
  5996. beamLight.Color = Color3.new(vertexColor.x, vertexColor.y, vertexColor.z)
  5997. beamMesh.Scale = Vector3.new(radius * scale, 9000, radius * scale)
  5998. beamMesh.VertexColor = vertexColor
  5999. beamGlowMesh1.Scale = Vector3.new(1.2 * radius * glowScale1, 9000, 1.2 * radius * glowScale1)
  6000. beamGlowMesh1.VertexColor = vertexColor
  6001. beamGlowMesh2.Scale = Vector3.new(1.2 * radius * glowScale2, 9000, 1.2 * radius * glowScale2)
  6002. beamGlowMesh2.VertexColor = vertexColor
  6003. RunService.Stepped:wait()
  6004. gameTime = TaskScheduler.GetCurrentTime()
  6005. if frame <= 2 then
  6006. local explosion = Instance.new("Explosion")
  6007. explosion.BlastPressure = (1 - progress) * blastPressure
  6008. explosion.BlastRadius = (1 - progress) * power
  6009. explosion.Position = target
  6010. explosion.Parent = Workspace
  6011. if frame == 2 then
  6012. sound:Play()
  6013. end
  6014. end
  6015. end
  6016. pcall(beamPart.Destroy, beamPart)
  6017. explosionHitConnection:disconnect()
  6018. end
  6019. function GraphicalEffects.SpaceHyperBeam(target, power, duration, radius, height, deviation)
  6020. TaskScheduler.Start(GraphicalEffects.FireSpaceHyperBeam, target, power or 12, duration or 1.5, radius or 6, height or 600, deviation or 20)
  6021. end
  6022. -- Magic Circle
  6023. GraphicalEffects.magicCircleData = {}
  6024. GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET = 6.25
  6025. function GraphicalEffects.AnimateMagicCircle(data)
  6026. local frame, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, duration,
  6027.  
  6028. stay, magic_circle_adornee_func, magic_circle_offset = unpack(data)
  6029. frame = frame + 1
  6030. data[1] = frame
  6031. local transparency = (frame / duration) ^ stay
  6032. local opacity = 1 - transparency
  6033. if frame == duration then
  6034. pcall(Game.Destroy, magic_circle_model)
  6035. GraphicalEffects.magicCircleData[data] = nil
  6036. else
  6037. if magic_circle_model.Parent ~= Workspace then
  6038. pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
  6039. end
  6040. local magic_circle_adornee = magic_circle_adornee_func()
  6041. magic_circle_position = magic_circle_adornee.Position + direction * magic_circle_offset
  6042. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
  6043.  
  6044. 25)
  6045. magic_circle_part.CFrame = magic_circle_cframe
  6046. magic_circle_light.Brightness = opacity
  6047. magic_circle_decal_back.Transparency = transparency
  6048. magic_circle_decal_front.Transparency = transparency
  6049. end
  6050. end
  6051. function GraphicalEffects.CreateMagicCircle(target, magic_circle_scale, magic_circle_image, light_color, duration, stay, magic_circle_adornee_func,
  6052.  
  6053. magic_circle_offset)
  6054. local magic_circle_adornee = magic_circle_adornee_func()
  6055. if magic_circle_adornee then
  6056. local origin = magic_circle_adornee.Position
  6057. local direction = (target - origin).unit
  6058. local magic_circle_position = origin + direction * magic_circle_offset
  6059. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  6060. local magic_circle_model = Instance.new("Model")
  6061. local magic_circle_part = Instance.new("Part", magic_circle_model)
  6062. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  6063. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  6064. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  6065. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  6066. magic_circle_model.Archivable = false
  6067. magic_circle_part.Anchored = true
  6068. magic_circle_part.BottomSurface = "Smooth"
  6069. magic_circle_part.CanCollide = false
  6070. magic_circle_part.CFrame = magic_circle_cframe
  6071. magic_circle_part.FormFactor = "Custom"
  6072. magic_circle_part.Locked = true
  6073. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  6074. magic_circle_part.TopSurface = "Smooth"
  6075. magic_circle_part.Transparency = 1
  6076. magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  6077. magic_circle_light.Color = light_color
  6078. magic_circle_light.Range = 16 * magic_circle_scale
  6079. magic_circle_light.Shadows = true
  6080. magic_circle_decal_back.Face = "Back"
  6081. magic_circle_decal_back.Texture = magic_circle_image
  6082. magic_circle_decal_front.Face = "Front"
  6083. magic_circle_decal_front.Texture = magic_circle_image
  6084. magic_circle_model.Parent = Workspace
  6085. local data = {0, direction, magic_circle_model, magic_circle_part, magic_circle_light, magic_circle_decal_back, magic_circle_decal_front,
  6086.  
  6087. duration, stay, magic_circle_adornee_func, magic_circle_offset}
  6088. GraphicalEffects.magicCircleData[data] = true
  6089. return data
  6090. end
  6091. end
  6092. -- Laser of Death
  6093. GraphicalEffects.LASER_WIDTH = 0.15
  6094. GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE = 6.25
  6095. GraphicalEffects.laser_data = {}
  6096. --GraphicalEffects.fragmentation = {}
  6097. function GraphicalEffects.AnimateLaserOfDeath(data)
  6098. local frame, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part, magic_circle_light,
  6099.  
  6100. magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay, light_effects =
  6101.  
  6102. unpack(data)
  6103. local laser_color = laser_part.Color
  6104. frame = frame + 1
  6105. data[1] = frame
  6106. local transparency = (frame / duration) ^ stay
  6107. local opacity = 1 - transparency
  6108. if frame == 2 then
  6109. sound:Play()
  6110. end
  6111. if frame == duration then
  6112. pcall(Game.Destroy, magic_circle_model)
  6113. GraphicalEffects.laser_data[data] = nil
  6114. else
  6115. if magic_circle_model.Parent ~= Workspace then
  6116. pcall(Utility.SetProperty, magic_circle_model, "Parent", Workspace)
  6117. end
  6118. local laser_distance = 0
  6119. local origin = chatAdornee.CFrame
  6120. if not light_effects then
  6121. direction = (origin * directionOrientation - origin.p).unit
  6122. end
  6123. local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  6124. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0, math.tau * frame /
  6125.  
  6126. 25)
  6127. local loop_scale = (laser_scale - 1) / 10
  6128. for x_offset = -loop_scale, loop_scale, 2 do
  6129. for y_offset = -loop_scale, loop_scale, 2 do
  6130. local origin_position = magic_circle_cframe * Vector3.new(x_offset, y_offset, 0)
  6131. for index = 1, 8 do
  6132. local part, position
  6133. for ray_index = 1, 10 do
  6134. local ray = Ray.new(origin_position + direction * (999 * (ray_index - 1)), direction * 999)
  6135. part, position = Workspace:FindPartOnRay(ray, magic_circle_model)
  6136. if part then
  6137. break
  6138. end
  6139. end
  6140. if part then
  6141. laser_distance = (position - origin_position).magnitude
  6142. if frame % 8 == 1 and index == 1 then
  6143. Instance.new("Explosion", Workspace).Position = position
  6144. end
  6145. if not part:IsA("Terrain") then
  6146. pcall(part.BreakJoints, part)
  6147. local is_block = part:IsA("Part") and part.Shape == Enum.PartType.Block
  6148. local mass = part:GetMass()
  6149. local size = part.Size
  6150. if (is_block and ((size.X < fragmentation_size and size.Y < fragmentation_size and size.Z <
  6151.  
  6152. fragmentation_size) or (not part.Anchored and mass < 750))) or (not is_block and mass < 250000) then
  6153. local part_transparency = math.max(part.Transparency + 0.007 * fragmentation_size, 0.5)
  6154. if part_transparency >= 0.5 then -- temporarily to minimize debris
  6155. pcall(Game.Destroy, part)
  6156. else
  6157. local cframe = part.CFrame
  6158. part.Anchored = false
  6159. part.BrickColor = BrickColor.new("Medium stone grey")
  6160. part.CanCollide = true
  6161. if part:IsA("FormFactorPart") then
  6162. part.FormFactor = "Custom"
  6163. end
  6164. part.Size = size - Vector3.new(0.135, 0.135, 0.135) * fragmentation_size
  6165. part.Transparency = part_transparency
  6166. part.CFrame = cframe + direction * 5
  6167. part.Velocity = part.Velocity + direction * 40
  6168. end
  6169. elseif is_block then
  6170. local parts = {part}
  6171. local model = Instance.new("Model", part.Parent)
  6172. model.Name = "Fragments"
  6173. if size.X >= fragmentation_size then
  6174. size = Vector3.new(0.5, 1, 1) * size
  6175. local archivable = part.Archivable
  6176. local cframe = part.CFrame
  6177. part.FormFactor = "Custom"
  6178. part.Size = size
  6179. part.Archivable = true
  6180. local part_clone = part:Clone()
  6181. part.Archivable = archivable
  6182. part_clone.Archivable = archivable
  6183. part.CFrame = cframe * CFrame.new(-0.5 * size.X, 0, 0)
  6184. part_clone.CFrame = cframe * CFrame.new(0.5 * size.X, 0, 0)
  6185. part_clone.Parent = model
  6186. parts[2] = part_clone
  6187. end
  6188. if size.Y >= fragmentation_size then
  6189. size = Vector3.new(1, 0.5, 1) * size
  6190. for part_index = 1, #parts do
  6191. local part = parts[part_index]
  6192. local archivable = part.Archivable
  6193. local cframe = part.CFrame
  6194. part.FormFactor = "Custom"
  6195. part.Size = size
  6196. part.Archivable = true
  6197. local part_clone = part:Clone()
  6198. part.Archivable = archivable
  6199. part_clone.Archivable = archivable
  6200. part.CFrame = cframe * CFrame.new(0, -0.5 * size.Y, 0)
  6201. part_clone.CFrame = cframe * CFrame.new(0, 0.5 * size.Y, 0)
  6202. part_clone.Parent = model
  6203. table.insert(parts, part_clone)
  6204. end
  6205. end
  6206. if size.Z >= fragmentation_size then
  6207. size = Vector3.new(1, 1, 0.5) * size
  6208. for part_index = 1, #parts do
  6209. local part = parts[part_index]
  6210. local archivable = part.Archivable
  6211. local cframe = part.CFrame
  6212. part.FormFactor = "Custom"
  6213. part.Size = size
  6214. part.Archivable = true
  6215. local part_clone = part:Clone()
  6216. part.Archivable = archivable
  6217. part_clone.Archivable = archivable
  6218. part.CFrame = cframe * CFrame.new(0, 0, -0.5 * size.Z)
  6219. part_clone.CFrame = cframe * CFrame.new(0, 0, 0.5 * size.Z)
  6220. part_clone.Parent = model
  6221. table.insert(parts, part_clone)
  6222. end
  6223. end
  6224. for _, part in ipairs(parts) do
  6225. part:MakeJoints()
  6226. end
  6227. else
  6228. break
  6229. end
  6230. end
  6231. else
  6232. laser_distance = 9990
  6233. break
  6234. end
  6235. end
  6236. end
  6237. end
  6238. local laser_cframe = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  6239. local laser_width = GraphicalEffects.LASER_WIDTH * opacity * laser_scale
  6240. local laser_mesh_offset = Vector3.new(0, 0.5 * laser_distance, 0)
  6241. laser_part.CFrame = laser_cframe
  6242. if laser_effects then
  6243. local laser_effect_data_1, laser_effect_data_2 = laser_effects[1], laser_effects[2]
  6244. local laser_effect_1, laser_effect_mesh_1 = laser_effect_data_1[1], laser_effect_data_1[2]
  6245. local laser_effect_2, laser_effect_mesh_2 = laser_effect_data_2[1], laser_effect_data_2[2]
  6246. laser_effect_1.CFrame = laser_cframe
  6247. laser_effect_2.CFrame = laser_cframe
  6248. laser_effect_mesh_1.Offset = laser_mesh_offset
  6249. laser_effect_mesh_2.Offset = laser_mesh_offset
  6250. local game_time = time()
  6251. local effect_scale_1 = 0.5 + 0.5 * math.sin(16 * math.pi * game_time)
  6252. local effect_scale_2 = 0.5 + 0.5 * math.cos(16 * math.pi * game_time)
  6253. laser_effect_mesh_1.Scale = 5 * Vector3.new(laser_width * effect_scale_1, laser_distance, laser_width * effect_scale_1)
  6254. laser_effect_mesh_2.Scale = 5 * Vector3.new(laser_width * effect_scale_2, laser_distance, laser_width * effect_scale_2)
  6255. laser_width = laser_width * 0.25
  6256. end
  6257. laser_mesh.Offset = laser_mesh_offset
  6258. laser_mesh.Scale = 5 * Vector3.new(laser_width, laser_distance, laser_width)
  6259. magic_circle_part.CFrame = magic_circle_cframe
  6260. magic_circle_light.Brightness = opacity
  6261. magic_circle_decal_back.Transparency = transparency
  6262. magic_circle_decal_front.Transparency = transparency
  6263. if light_effects then
  6264. for index, data in ipairs(laser_lights) do
  6265. local laser_spotlight_part, laser_spotlight = data[1], data[2]
  6266. local laser_spotlight_offset = 30 * (index - 1)
  6267. if laser_spotlight_offset <= laser_distance then
  6268. laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -laser_spotlight_offset)
  6269. laser_spotlight.Brightness = opacity
  6270. laser_spotlight.Enabled = true
  6271. else
  6272. laser_spotlight.Enabled = false
  6273. end
  6274. end
  6275. end
  6276. end
  6277. end
  6278. function GraphicalEffects.ShootLaserOfDeath(target, data)
  6279. if chatAdornee then
  6280. data = data or {}
  6281. local brickcolor = data.brickcolor or BrickColor.new("Really black")
  6282. local duration = data.duration or 40
  6283. local fragmentation_size = data.fragmentation_size or 3
  6284. local laser_scale = data.laser_scale or 1
  6285. local light_color = data.light_color or Color3.new(1, 0.5, 1)
  6286. local magic_circle_image = data.magic_circle_image or "rbxassetid://122610943"
  6287. local magic_circle_scale = data.magic_circle_scale or 1
  6288. local sound_volume = data.sound_volume or 1 / 3
  6289. local special_effects = data.special_effects
  6290. local stay = data.stay or 4
  6291. local origin = chatAdornee.CFrame
  6292. local directionOrientation = origin:pointToObjectSpace(target)
  6293. local direction = (target - origin.p).unit
  6294. local magic_circle_position = origin.p + direction * GraphicalEffects.LASER_MAGIC_CIRCLE_DISTANCE
  6295. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  6296. local magic_circle_model = Instance.new("Model")
  6297. local laser_part = Instance.new("Part", magic_circle_model)
  6298. local laser_mesh = Instance.new("CylinderMesh", laser_part)
  6299. local magic_circle_part = Instance.new("Part", magic_circle_model)
  6300. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  6301. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  6302. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  6303. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  6304. local sound = Instance.new("Sound", magic_circle_part)
  6305. sound.Pitch = 1.25
  6306. sound.SoundId = "rbxassetid://2248511"
  6307. sound.Volume = sound_volume
  6308. magic_circle_model.Archivable = false
  6309. laser_part.Anchored = true
  6310. laser_part.BottomSurface = "Smooth"
  6311. laser_part.BrickColor = brickcolor
  6312. laser_part.CanCollide = false
  6313. laser_part.CFrame = magic_circle_cframe * CFrame.Angles(-0.5 * math.pi, 0, 0)
  6314. laser_part.FormFactor = "Custom"
  6315. laser_part.Locked = true
  6316. laser_part.Size = Vector3.new(0.2, 0.2, 0.2)
  6317. laser_part.TopSurface = "Smooth"
  6318. laser_mesh.Offset = Vector3.new(0, 0, 0)
  6319. laser_mesh.Name = "Mesh"
  6320. laser_mesh.Scale = 5 * laser_scale * Vector3.new(GraphicalEffects.LASER_WIDTH, 0, GraphicalEffects.LASER_WIDTH)
  6321. magic_circle_part.Anchored = true
  6322. magic_circle_part.BottomSurface = "Smooth"
  6323. magic_circle_part.CanCollide = false
  6324. magic_circle_part.CFrame = magic_circle_cframe
  6325. magic_circle_part.FormFactor = "Custom"
  6326. magic_circle_part.Locked = true
  6327. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  6328. magic_circle_part.TopSurface = "Smooth"
  6329. magic_circle_part.Transparency = 1
  6330. magic_circle_mesh.Scale = Vector3.new(60, 60, 0) * magic_circle_scale
  6331. magic_circle_light.Color = light_color
  6332. magic_circle_light.Range = 16 * magic_circle_scale
  6333. magic_circle_light.Shadows = true
  6334. magic_circle_decal_back.Face = "Back"
  6335. magic_circle_decal_back.Texture = magic_circle_image
  6336. magic_circle_decal_front.Face = "Front"
  6337. magic_circle_decal_front.Texture = magic_circle_image
  6338. magic_circle_model.Parent = Workspace
  6339. local laser_color = brickcolor.Color
  6340. local laser_lights = {}
  6341. local light_effects = laser_color.r + laser_color.g + laser_color.b > 0.25
  6342. if light_effects then
  6343. local laser_spotlight_part_template = Instance.new("Part")
  6344. local laser_spotlight_light_template = Instance.new("SpotLight", laser_spotlight_part_template)
  6345. laser_spotlight_part_template.Anchored = true
  6346. laser_spotlight_part_template.Anchored = true
  6347. laser_spotlight_part_template.BottomSurface = "Smooth"
  6348. laser_spotlight_part_template.CanCollide = false
  6349. laser_spotlight_part_template.FormFactor = "Custom"
  6350. laser_spotlight_part_template.Locked = true
  6351. laser_spotlight_part_template.Size = Vector3.new(0.2, 0.2, 0.2)
  6352. laser_spotlight_part_template.TopSurface = "Smooth"
  6353. laser_spotlight_part_template.Transparency = 1
  6354. laser_spotlight_light_template.Angle = 45
  6355. laser_spotlight_light_template.Color = laser_color
  6356. laser_spotlight_light_template.Enabled = true
  6357. laser_spotlight_light_template.Name = "Light"
  6358. laser_spotlight_light_template.Range = 60
  6359. for index = 1, 40 do
  6360. local laser_spotlight_part = laser_spotlight_part_template:Clone()
  6361. laser_spotlight_part.CFrame = magic_circle_cframe * CFrame.new(0, 0, -30 * (index - 1))
  6362. laser_spotlight_part.Parent = magic_circle_model
  6363. laser_lights[index] = {laser_spotlight_part, laser_spotlight_part.Light}
  6364. end
  6365. end
  6366. local laser_effects
  6367. if special_effects then
  6368. laser_effects = {}
  6369. local laser_effect_1 = laser_part:Clone()
  6370. laser_effect_1.BrickColor = special_effects
  6371. laser_effect_1.Transparency = 0.5
  6372. local laser_effect_2 = laser_effect_1:Clone()
  6373. laser_effects[1], laser_effects[2] = {laser_effect_1, laser_effect_1.Mesh}, {laser_effect_2, laser_effect_2.Mesh}
  6374. laser_effect_1.Parent = magic_circle_model
  6375. laser_effect_2.Parent = magic_circle_model
  6376. end
  6377. GraphicalEffects.laser_data[{0, directionOrientation, direction, magic_circle_model, laser_part, laser_mesh, magic_circle_part,
  6378.  
  6379. magic_circle_light, magic_circle_decal_back, magic_circle_decal_front, sound, laser_scale, fragmentation_size, duration, laser_lights, laser_effects, stay,
  6380.  
  6381. light_effects}] = true
  6382. end
  6383. end
  6384. -- Sapient Rock
  6385. function GraphicalEffects.SpawnSapientRock(position)
  6386. local part = Instance.new("Part", Workspace)
  6387. local size = 8 + math.random(0, 5)
  6388. part.BottomSurface = "Smooth"
  6389. part.TopSurface = "Smooth"
  6390. part.Material = "Slate"
  6391. part.Locked = true
  6392. part.Shape = "Ball"
  6393. part.FormFactor = "Custom"
  6394. part.Size = Vector3.new(size, size, size)
  6395. part.Position = position
  6396. local bodypos = Instance.new("BodyPosition", part)
  6397. bodypos.maxForce = Vector3.new(0, 0, 0)
  6398. local angry = false
  6399. local damage_ready = true
  6400. local torso_following
  6401. local torso_changed = -1000
  6402. local touched_conn = part.Touched:connect(function(hit)
  6403. local character = hit.Parent
  6404. if character then
  6405. local humanoid
  6406. for _, child in ipairs(character:GetChildren()) do
  6407. if child:IsA("Humanoid") then
  6408. humanoid = child
  6409. break
  6410. end
  6411. end
  6412. if humanoid then
  6413. if angry then
  6414. if damage_ready then
  6415. damage_ready = false
  6416. humanoid:TakeDamage(100)
  6417. wait(1)
  6418. damage_ready = true
  6419. angry = false
  6420. part.BrickColor = BrickColor.new("Medium stone grey")
  6421. end
  6422. else
  6423. local torso = humanoid.Torso
  6424. if torso then
  6425. torso_following = torso
  6426. torso_changed = tick()
  6427. end
  6428. end
  6429. end
  6430. end
  6431. end)
  6432. TaskScheduler.Start(function()
  6433. while part.Parent == Workspace do
  6434. if torso_following then
  6435. bodypos.position = torso_following.Position
  6436. if tick() - torso_changed > 60 or not torso_following.Parent then
  6437. torso_following = nil
  6438. bodypos.maxForce = Vector3.new(0, 0, 0)
  6439. angry = false
  6440. part.BrickColor = BrickColor.new("Medium stone grey")
  6441. else
  6442. local speed = angry and Vector3.new(16, 16, 16) or Vector3.new(6, 0, 6)
  6443. bodypos.maxForce = part:GetMass() * speed
  6444. if part.Position.Y < -250 then
  6445. part.Velocity = Vector3.new()
  6446. part.Position = torso_following.Position + Vector3.new(0, 80, 0)
  6447. part.BrickColor = BrickColor.new("Bright red")
  6448. angry = true
  6449. torso_changed = tick()
  6450. end
  6451. end
  6452. end
  6453. RunService.Stepped:wait()
  6454. end
  6455. touched_conn:disconnect()
  6456. end)
  6457. TaskScheduler.Start(function()
  6458. while part.Parent == Workspace do
  6459. wait(25 + math.random() * 10)
  6460. local next_size = 8 + math.random() * 5
  6461. if math.random(100) == 1 then
  6462. next_size = next_size * (2 + 6 * math.random())
  6463. end
  6464. next_size = math.floor(next_size + 0.5)
  6465. local start_time = tick()
  6466. local mesh = Instance.new("SpecialMesh", part)
  6467. mesh.MeshType = "Sphere"
  6468. repeat
  6469. local elapsed_time = tick() - start_time
  6470. local alpha = math.cos(elapsed_time * math.pi * 0.5)
  6471. local interpolated_size = size * alpha + next_size * (1 - alpha)
  6472. local size_vector = Vector3.new(interpolated_size, interpolated_size, interpolated_size)
  6473. local cframe = part.CFrame
  6474. part.Size = size_vector
  6475. part.CFrame = cframe
  6476. mesh.Scale = size_vector / part.Size
  6477. RunService.Stepped:wait()
  6478. until tick() - start_time >= 1
  6479. mesh:Destroy()
  6480. local cframe = part.CFrame
  6481. part.Size = Vector3.new(next_size, next_size, next_size)
  6482. part.CFrame = cframe
  6483. size = next_size
  6484. end
  6485. end)
  6486. end
  6487. -- Crystal ring
  6488. function GraphicalEffects.CrystalRing(data)
  6489. data = data or {}
  6490. local crystal_count = data.crystal_count or 10
  6491. local crystal_color = data.crystal_color or BrickColor.new("Bright red")
  6492. local crystal_scale = data.crystal_scale or Vector3.new(2 / 3, 2, 2 / 3)
  6493. local radius = radius or 1.25 * crystal_count / math.pi
  6494. local spawn_duration = data.spawn_duration or 0.065
  6495. local full_spawn_duration = spawn_duration * crystal_count
  6496. local float_duration = data.float_duration or 5
  6497. local wave_amplitude = data.wave_amplitude or 0.5
  6498. local wave_period = data.wave_period or 1
  6499. local appear_duration = data.appear_duration or 0.1
  6500. local disappear_duration = data.disappear_duration or 0.5
  6501. local base_part = data.base_part
  6502. local offset_cframe
  6503. if data.position then
  6504. offset_cframe = CFrame.new(data.position)
  6505. if base_part then
  6506. offset_cframe = base_part.CFrame:toObjectSpace(offset_cframe)
  6507. end
  6508. else
  6509. offset_cframe = CFrame.new()
  6510. end
  6511. local crystal_template = Instance.new("Part")
  6512. crystal_template.Anchored = true
  6513. crystal_template.Locked = true
  6514. crystal_template.CanCollide = false
  6515. crystal_template.BottomSurface = "Smooth"
  6516. crystal_template.TopSurface = "Smooth"
  6517. crystal_template.BrickColor = crystal_color
  6518. crystal_template.FormFactor = "Symmetric"
  6519. crystal_template.Size = Vector3.new(1, 1, 1)
  6520. local crystal_light = Instance.new("PointLight", crystal_template)
  6521. crystal_light.Brightness = 0.1 / crystal_count
  6522. crystal_light.Color = crystal_color.Color
  6523. crystal_light.Name = "Light"
  6524. crystal_light.Range = radius
  6525. crystal_light.Shadows = true
  6526. local crystal_mesh = Instance.new("SpecialMesh", crystal_template)
  6527. crystal_mesh.MeshId = "rbxassetid://9756362"
  6528. crystal_mesh.MeshType = "FileMesh"
  6529. crystal_mesh.Name = "Mesh"
  6530. crystal_mesh.Scale = crystal_scale
  6531. local crystal_model = Instance.new("Model")
  6532. crystal_model.Archivable = false
  6533. crystal_model.Name = "Crystal Model"
  6534. crystal_model.Parent = Workspace
  6535. local crystals = {}
  6536. local lights = {}
  6537. local meshes = {}
  6538. for index = 1, crystal_count do
  6539. local crystal = crystal_template:Clone()
  6540. crystal.Parent = crystal_model
  6541. crystals[index] = crystal
  6542. lights[index] = crystal.Light
  6543. meshes[index] = crystal.Mesh
  6544. end
  6545. local start_time = tick()
  6546. repeat
  6547. local base_cframe = offset_cframe
  6548. if base_part then
  6549. base_cframe = base_part.CFrame * base_cframe
  6550. end
  6551. local elapsed_time = tick() - start_time
  6552. for index, crystal in ipairs(crystals) do
  6553. local crystal_time = elapsed_time - index * spawn_duration
  6554. local disappear_time = crystal_time - float_duration
  6555. local offset
  6556. if crystal_time < 0 then
  6557. offset = 0
  6558. elseif crystal_time < appear_duration then
  6559. offset = radius * crystal_time / appear_duration
  6560. else
  6561. offset = radius
  6562. end
  6563. local wave_offset
  6564. if disappear_time >= 0 then
  6565. local disappear_progress = disappear_time / disappear_duration
  6566. if disappear_progress > 1 then
  6567. if crystal.Parent then
  6568. crystal:Destroy()
  6569. end
  6570. else
  6571. local inverse_progress = 1 - disappear_progress
  6572. local light = lights[index]
  6573. local mesh = meshes[index]
  6574. crystal.BrickColor = BrickColor.new("Really black")
  6575. light.Brightness = 2 * inverse_progress
  6576. light.Range = 2 * radius
  6577. mesh.Scale = crystal_scale * inverse_progress
  6578. end
  6579. wave_offset = 0
  6580. else
  6581. wave_offset = wave_amplitude * math.sin(math.tau * (elapsed_time - index / crystal_count * 3) / wave_period)
  6582. end
  6583. local rotation_angle = (tick() * 0.5 + (index - 1) / crystal_count) % 1 * math.tau
  6584. crystal.CFrame = base_cframe * CFrame.Angles(0, rotation_angle, 0) * CFrame.new(0, wave_offset, -offset)
  6585. end
  6586. RunService.Stepped:wait()
  6587. until elapsed_time >= float_duration + full_spawn_duration + disappear_duration
  6588. if crystal_model.Parent then
  6589. crystal_model:Destroy()
  6590. end
  6591. end
  6592. -- Missiles
  6593. GraphicalEffects.missileData = {}
  6594. GraphicalEffects.missileParts = {}
  6595. function GraphicalEffects.AnimateMissile(data)
  6596. local frame, missilePart, targetPart, timeCreated, direction, touchedConnection, explodeRequested, bodyGyro, swooshSound, magicCircleData, lifeTime,
  6597.  
  6598. pointOnPart, flipped = unpack(data)
  6599. frame = frame + 1
  6600. data[1] = frame
  6601. if flipped then
  6602. direction = -direction
  6603. end
  6604. if frame <= 10 then
  6605. if frame == 2 then
  6606. swooshSound:Play()
  6607. end
  6608. missilePart.Anchored = true
  6609. local progress = frame / 10
  6610. missilePart.Size = Vector3.new(1, 1, progress * 4)
  6611. local magicCirclePart = magicCircleData[4]
  6612. local magicCirclePosition = magicCirclePart.Position
  6613. local missileOffset = 2 * progress * direction
  6614. local missilePosition = magicCirclePosition + missileOffset
  6615. missilePart.CFrame = CFrame.new(missilePosition, missilePosition + direction)
  6616. --missilePart.Transparency = 0.5 * (1 - progress)
  6617. if frame == 10 then
  6618. touchedConnection = missilePart.Touched:connect(function(hit)
  6619. if hit.CanCollide and hit.Parent and not GraphicalEffects.missileParts[hit] then
  6620. touchedConnection:disconnect()
  6621. data[7] = true
  6622. end
  6623. end)
  6624. data[6] = touchedConnection
  6625. end
  6626. else
  6627. missilePart.Anchored = false
  6628. local missilePosition = missilePart.Position
  6629. local targetPosition = targetPart.CFrame * pointOnPart
  6630. local distanceVector = targetPosition - missilePosition
  6631. local elapsedTime = time() - timeCreated
  6632. local targetParent = targetPart.Parent
  6633. if explodeRequested or (targetParent and distanceVector.magnitude < 10) or elapsedTime > lifeTime then
  6634. GraphicalEffects.missileData[data] = nil
  6635. GraphicalEffects.missileParts[missilePart] = nil
  6636. touchedConnection:disconnect()
  6637. if missilePart.Parent then
  6638. missilePart:Destroy()
  6639. local explosion = Instance.new("Explosion")
  6640. explosion.BlastRadius = 12.5
  6641. explosion.Position = missilePosition
  6642. local explosionHitConnection = explosion.Hit:connect(function(hit, distance)
  6643. local missileData = GraphicalEffects.missileParts[hit]
  6644. if missileData and distance < 3 then
  6645. missileData[7] = true
  6646. else
  6647. pcall(hit.BreakJoints, hit)
  6648. end
  6649. end)
  6650. explosion.Parent = Workspace
  6651. TaskScheduler.Schedule(1, explosionHitConnection.disconnect, explosionHitConnection)
  6652. end
  6653. else
  6654. local targetInWorkspace = targetPart:IsDescendantOf(Workspace)
  6655. if targetInWorkspace then
  6656. direction = distanceVector.unit
  6657. data[5] = direction
  6658. end
  6659. local speed = 14 + elapsedTime * 10
  6660. local gyroD
  6661. if elapsedTime < 42.5 and targetInWorkspace then
  6662. gyroD = 1000 - elapsedTime * 15
  6663. else
  6664. gyroD = 100
  6665. bodyGyro.maxTorque = Vector3.new(0, 0, 0)
  6666. if elapsedTime + 7.5 < lifeTime then
  6667. data[11] = elapsedTime + 7.5
  6668. end
  6669. end
  6670. bodyGyro.D = gyroD
  6671. bodyGyro.cframe = CFrame.new(Vector3.new(), direction)
  6672. missilePart.Velocity = missilePart.CFrame.lookVector * speed
  6673. end
  6674. end
  6675. end
  6676. function GraphicalEffects.ShootMissile(targetPart, pointOnPart, direction, magic_circle_adornee_func, magic_circle_offset, flipped)
  6677. if not magic_circle_offset then
  6678. magic_circle_offset = GraphicalEffects.MAGIC_CIRCLE_DEFAULT_OFFSET
  6679. end
  6680. local targetPosition = targetPart.Position
  6681. local headPosition = chatAdornee.Position
  6682. local origin = CFrame.new(headPosition, headPosition + direction) + direction * magic_circle_offset
  6683. local missilePart = Instance.new("Part")
  6684. local antiGravityForce = Instance.new("BodyForce", missilePart)
  6685. local bodyGyro = Instance.new("BodyGyro", missilePart)
  6686. local explosionSound = Instance.new("Sound", missilePart)
  6687. local swooshSound = Instance.new("Sound", missilePart)
  6688. antiGravityForce.force = Vector3.new(0, 196.2 * 4, 0)
  6689. bodyGyro.D = 1000
  6690. bodyGyro.maxTorque = Vector3.new(1, 1, 1)
  6691. explosionSound.PlayOnRemove = true
  6692. explosionSound.SoundId = "rbxasset://sounds/collide.wav"
  6693. explosionSound.Volume = 1
  6694. missilePart.Anchored = true
  6695. missilePart.BackSurface = "Studs"
  6696. missilePart.BottomSurface = "Studs"
  6697. missilePart.BrickColor = BrickColor.Red()
  6698. missilePart.CFrame = origin
  6699. missilePart.FormFactor = "Custom"
  6700. missilePart.FrontSurface = "Studs"
  6701. missilePart.LeftSurface = "Studs"
  6702. missilePart.Locked = true
  6703. missilePart.RightSurface = "Studs"
  6704. missilePart.Size = Vector3.new(1, 1, 0.2)
  6705. missilePart.TopSurface = "Studs"
  6706. --missilePart.Transparency = 0.5
  6707. swooshSound.Looped = true
  6708. swooshSound.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  6709. swooshSound.Volume = 0.7
  6710. local magicCircleData = GraphicalEffects.CreateMagicCircle(headPosition + direction * 1000, 0.875, "rbxassetid://127033719", Color3.new(1, 1, 1),
  6711.  
  6712. 40, 4, magic_circle_adornee_func or function() return chatAdornee end, magic_circle_offset)
  6713. local data = {0, missilePart, targetPart, time(), direction, false, false, bodyGyro, swooshSound, magicCircleData, 50, pointOnPart, flipped}
  6714. missilePart.Parent = Workspace
  6715. GraphicalEffects.missileData[data] = true
  6716. GraphicalEffects.missileParts[missilePart] = data
  6717. end
  6718. -- Joint crap
  6719. function GraphicalEffects.CubicInterpolate(y0, y1, y2, y3, mu)
  6720. local a0, a1, a2, a3, mu2
  6721. mu2 = mu * mu
  6722. a0 = y3 - y2 - y0 + y1
  6723. a1 = y0 - y1 - a0
  6724. a2 = y2 - y0
  6725. a3 = y1
  6726. return a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3
  6727. end
  6728. function GraphicalEffects.JointCrap(model, cycletime)
  6729. if model then
  6730. local cycletime = cycletime or (0.75 * (1 + math.random() * 4))
  6731. local offsetradius = 0.75
  6732. local rotationoffset = math.pi
  6733. local joints = {}
  6734. local stack = model:GetChildren()
  6735. while #stack ~= 0 do
  6736. local object = stack[#stack]
  6737. table.remove(stack)
  6738. for index, child in ipairs(object:GetChildren()) do
  6739. table.insert(stack, child)
  6740. end
  6741. if object:IsA("JointInstance") then
  6742. table.insert(joints, object)
  6743. end
  6744. end
  6745. local rot0 = {}
  6746. local rot1 = {}
  6747. local rot2 = {}
  6748. local rot3 = {}
  6749. local rot4 = {}
  6750. for index, joint in ipairs(joints) do
  6751. local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  6752. local rot = Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  6753. rot0[index] = {joint.C0, joint.C1}
  6754. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  6755. rot2[index] = {pos, rot}
  6756. pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  6757. rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  6758. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  6759. rot3[index] = {pos, rot}
  6760. pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  6761. rot = rot + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  6762. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  6763. rot4[index] = {pos, rot}
  6764. end
  6765. while model.Parent do
  6766. for i, j in ipairs(joints) do
  6767. local pos = Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * offsetradius
  6768. local rot = rot4[i][2] + Vector3.new(math.random(), math.random(), math.random()) * rotationoffset
  6769. rot = Vector3.new(rot.x % (math.tau), rot.y % (math.tau), rot.z % (math.tau))
  6770. rot1[i], rot2[i], rot3[i], rot4[i] = rot2[i], rot3[i], rot4[i], {pos, rot}
  6771. end
  6772. local start = tick()
  6773. while true do
  6774. local ctime = tick()
  6775. local elapsed = ctime - start
  6776. if elapsed > cycletime then
  6777. break
  6778. end
  6779. local progress = elapsed / cycletime
  6780. for index, joint in ipairs(joints) do
  6781. local v0, v1, v2, v3, v4 = rot0[index], rot1[index], rot2[index], rot3[index], rot4[index]
  6782. 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]
  6783. local px = GraphicalEffects.CubicInterpolate(p1.x, p2.x, p3.x, p4.x, progress)
  6784. local py = GraphicalEffects.CubicInterpolate(p1.y, p2.y, p3.y, p4.y, progress)
  6785. local pz = GraphicalEffects.CubicInterpolate(p1.z, p2.z, p3.z, p4.z, progress)
  6786. local rx = GraphicalEffects.CubicInterpolate(r1.x, r2.x, r3.x, r4.x, progress)
  6787. local ry = GraphicalEffects.CubicInterpolate(r1.y, r2.y, r3.y, r4.y, progress)
  6788. local rz = GraphicalEffects.CubicInterpolate(r1.z, r2.z, r3.z, r4.z, progress)
  6789. local cframe = CFrame.new(px, py, pz) * CFrame.Angles(rx, ry, rz)
  6790. joint.C0 = v0[1] * cframe
  6791. joint.C1 = v0[2] * cframe:inverse()
  6792. end
  6793. RunService.Stepped:wait()
  6794. end
  6795. end
  6796. end
  6797. end
  6798. -- Destruction spell
  6799. do
  6800. GraphicalEffects.destructionSpellSpeed = 5
  6801. GraphicalEffects.destructionSpellEffectSize = 2
  6802. GraphicalEffects.destructionSpellExplosionRate = 10
  6803. GraphicalEffects.destructionSpellFadeDuration = 120
  6804. local partProto = Instance.new("Part")
  6805. local partProtoDecal1 = Instance.new("Decal", partProto)
  6806. local partProtoDecal2 = Instance.new("Decal", partProto)
  6807. local partProtoGyro = Instance.new("BodyGyro", partProto)
  6808. local partProtoPosition = Instance.new("BodyPosition", partProto)
  6809. partProto.CanCollide = false
  6810. partProto.FormFactor = "Custom"
  6811. partProto.Transparency = 1
  6812. partProtoDecal1.Face = "Bottom"
  6813. partProtoDecal1.Texture = "rbxassetid://106508453"
  6814. partProtoDecal2.Face = "Top"
  6815. partProtoDecal2.Texture = "rbxassetid://106508453"
  6816. partProtoGyro.Name = "gyro"
  6817. partProtoGyro.P = 1e6
  6818. partProtoGyro.maxTorque = Vector3.new(1e9, 1e9, 1e9)
  6819. partProtoPosition.Name = "pos"
  6820. partProtoPosition.P = 1e4
  6821. partProtoPosition.maxForce = Vector3.new(1e9, 1e9, 1e9)
  6822. function GraphicalEffects.DestructionSpell(nodes)
  6823. local destroyTable = {}
  6824. local regionSizeX, regionSizeY, regionSizeZ
  6825. local function MagicalDestroyUnchecked(part)
  6826. local partSize = part.Size
  6827. if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ then
  6828. destroyTable[part] = true
  6829. part.Material = "Plastic"
  6830. local beginTransparency = part.Transparency
  6831. local fadeDuration = GraphicalEffects.destructionSpellFadeDuration
  6832. for i = 1, fadeDuration do
  6833. RunService.Stepped:wait()
  6834. part.Transparency = beginTransparency + (1 - beginTransparency) * (i / fadeDuration)
  6835. end
  6836. pcall(Game.Destroy, part)
  6837. destroyTable[part] = nil
  6838. end
  6839. end
  6840. local function MagicalDestroy(part)
  6841. if not destroyTable[part] then
  6842. MagicalDestroyUnchecked(part)
  6843. end
  6844. end
  6845. local function MagicalNodeFinalize(part, gyro, pos, conn)
  6846. part.Anchored = true
  6847. pcall(gyro.Destroy, gyro)
  6848. pcall(pos.Destroy, pos)
  6849. conn:disconnect()
  6850. end
  6851. local model = Instance.new("Model")
  6852. model.Archivable = false
  6853. model.Name = "Nolix Wrath"
  6854. model.Parent = Workspace
  6855. local connections = {}
  6856. local parts = {}
  6857. local partsHit = {}
  6858. local cleanupList = {}
  6859. local explosionRate = GraphicalEffects.destructionSpellExplosionRate
  6860. local effectSize = GraphicalEffects.destructionSpellEffectSize
  6861. partProto.Size = Vector3.new(effectSize, 0.2, effectSize)
  6862. local speed = GraphicalEffects.destructionSpellSpeed
  6863. local rateTimer = 0
  6864. local partRotation = CFrame.Angles(0, 0.5 * math.pi, 0)
  6865. local minX, minY, minZ, maxX, maxY, maxZ = math.huge, math.huge, math.huge, -math.huge, -math.huge, -math.huge
  6866. for index = 4, #nodes do
  6867. local v0, v1, v2, v3 = nodes[index - 3], nodes[index - 2], nodes[index - 1], nodes[index]
  6868. local p1 = v1
  6869. local count = math.ceil((v2 - v1).magnitude / effectSize)
  6870. local linearStep = (v2 - v1) / count
  6871. for i = 1, count do
  6872. local alpha = i / count
  6873. local p2 = GraphicalEffects.CubicInterpolate(v0, v1, v2, v3, alpha)
  6874. local center = 0.5 * (p1 + p2)
  6875. local offset = p2 - p1
  6876. local partId = #parts + 1
  6877. local hitList = {}
  6878. partsHit[partId] = hitList
  6879. local part = partProto:Clone()
  6880. local gyro = part.gyro
  6881. local pos = part.pos
  6882. local cframe = CFrame.new(center, center + offset) * partRotation
  6883. part.CFrame = cframe
  6884. gyro.cframe = cframe
  6885. pos.position = center
  6886. local posX, posY, posZ = center.X, center.Y, center.Z
  6887. if posX < minX then minX = posX end
  6888. if posY < minY then minY = posY end
  6889. if posZ < minZ then minZ = posZ end
  6890. if posX > maxX then maxX = posX end
  6891. if posY > maxY then maxY = posY end
  6892. if posZ > maxZ then maxZ = posZ end
  6893. Instance.new("BlockMesh", part).Scale = Vector3.new(offset.magnitude, 0, effectSize)
  6894. parts[partId] = part
  6895. destroyTable[part] = true
  6896. local conn = part.Touched:connect(function(hit)
  6897. if not destroyTable[hit] then
  6898. hitList[hit] = true
  6899. end
  6900. end)
  6901. part.Parent = model
  6902. p1 = p2
  6903. TaskScheduler.Schedule(0.125, MagicalNodeFinalize, part, gyro, pos, conn)
  6904. rateTimer = rateTimer + 1
  6905. while rateTimer >= speed do
  6906. RunService.Stepped:wait()
  6907. rateTimer = rateTimer - speed
  6908. end
  6909. end
  6910. end
  6911. local center = Vector3.new(minX + maxX, minY + maxY, minZ + maxZ) * 0.5
  6912. regionSizeX, regionSizeY, regionSizeZ = maxX - minX, maxY - minY, maxZ - minZ
  6913. wait(0.5)
  6914. rateTimer = 0
  6915. for index, part in pairs(parts) do
  6916. if index % explosionRate == 1 then
  6917. local partSize = part.Size
  6918. if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ then
  6919. local explosion = Instance.new("Explosion")
  6920. explosion.BlastPressure = 0
  6921. local position = part.Position
  6922. explosion.BlastRadius = (position - center).magnitude * 0.5
  6923. explosion.Position = (position + center) * 0.5
  6924. connections[#connections + 1] = explosion.Hit:connect(MagicalDestroy)
  6925. explosion.Parent = model
  6926. end
  6927. end
  6928. pcall(part.Destroy, part)
  6929. destroyTable[part] = nil
  6930. local hitList = partsHit[index]
  6931. for hit in pairs(hitList) do
  6932. local partSize = hit.Size
  6933. if partSize.X < regionSizeX and partSize.Y < regionSizeY and partSize.Z < regionSizeZ
  6934. and hit.Parent and not destroyTable[hit] then
  6935. TaskScheduler.Start(MagicalDestroyUnchecked, hit)
  6936. local explosion = Instance.new("Explosion")
  6937. explosion.BlastPressure = 0
  6938. explosion.BlastRadius = hit:GetMass() ^ (1 / 3) * 2
  6939. explosion.Position = hit.Position
  6940. connections[#connections + 1] = explosion.Hit:connect(MagicalDestroy)
  6941. explosion.Parent = model
  6942. end
  6943. end
  6944. rateTimer = rateTimer + 1
  6945. while rateTimer >= 4 * speed do
  6946. RunService.Stepped:wait()
  6947. rateTimer = rateTimer - 4 * speed
  6948. end
  6949. end
  6950. wait(0.25)
  6951. for _, connection in ipairs(connections) do
  6952. connection:disconnect()
  6953. end
  6954. end
  6955. end
  6956. -- MainLoop
  6957. function GraphicalEffects.MainLoop()
  6958. RunService.Stepped:wait()
  6959. for data in pairs(GraphicalEffects.magicCircleData) do
  6960. GraphicalEffects.AnimateMagicCircle(data)
  6961. end
  6962. for data in pairs(GraphicalEffects.laser_data) do
  6963. GraphicalEffects.AnimateLaserOfDeath(data)
  6964. end
  6965. for data in pairs(GraphicalEffects.missileData) do
  6966. GraphicalEffects.AnimateMissile(data)
  6967. end
  6968. end
  6969. TaskScheduler.Start(function()
  6970. while true do
  6971. GraphicalEffects.MainLoop()
  6972. end
  6973. end)
  6974. ]])
  6975. Module.Store("ServerControl", [=[
  6976. for _, child in ipairs(Game:GetChildren()) do
  6977. local success, className = pcall(function() return child.ClassName end)
  6978. if success and className == "NetworkServer" then
  6979. NetworkServer = child
  6980. break
  6981. end
  6982. end
  6983. ServerControl.banished_names = {}
  6984. for _, name in ipairs({
  6985. "12345678910jaijai",
  6986. "56awesome56",
  6987. "aleksa12432",
  6988. "blowup998",
  6989. "christmasboy",
  6990. "coolythe94",
  6991. "dalvo546",
  6992. "ENCRYPTEDis",
  6993. "fanoftheforgotten",
  6994. "goldenarrow97",
  6995. "Guest101632",
  6996. "hgbvcgdhgfds",
  6997. "IlIlXxxxxxXX12",
  6998. "InfiniteDeathKiller",
  6999. "JTHKILL99",
  7000. "liIlilILLIilIlil",
  7001. "LuaHat",
  7002. "LuaScriptPro",
  7003. "missKittyCatlove",
  7004. "MsDaisyroses",
  7005. "robloxmaster4491",
  7006. "rojdi3",
  7007. "s3sss3x",
  7008. "SBDESTROYER1",
  7009. "ScriptGuider",
  7010. "Scriptralize",
  7011. "ScriptTestingAccount",
  7012. "Scrupting",
  7013. "SomeMayCallMeATroll",
  7014. "starwill1",
  7015. "Starwill3",
  7016. "Toothyepic",
  7017. "trefor123"
  7018. }) do
  7019. ServerControl.banished_names[name:lower()] = true
  7020. end
  7021. for _, player in ipairs(Players:GetPlayers()) do
  7022. local playerName = tostring(player)
  7023. if ServerControl.banished_names[playerName:lower()] then
  7024. Logger.printf("Info", "Player %s has been kicked", playerName)
  7025. player:Kick()
  7026. end
  7027. end
  7028. ServerControl.LONG_STRING = string.rep("0123456789", 20001)
  7029. ServerControl.player_data = {}
  7030. function ServerControl.BanishName(name)
  7031. ServerControl.banished_names[name:lower()] = true
  7032. end
  7033. ServerControl.authorizedRemoteEvents = {}
  7034. ServerControl.MAX_MESSAGES = 2
  7035. ServerControl.message_list = {}
  7036. function ServerControl.BlockMessageSpam(object)
  7037. local message_list = ServerControl.message_list
  7038. local message_count = #message_list + 1
  7039. message_list[message_count] = object
  7040. if message_count > ServerControl.MAX_MESSAGES then
  7041. local new_message_count = 0
  7042. local new_message_list = {}
  7043. for message_index = 1, message_count do
  7044. local message_object = message_list[message_index]
  7045. local success, in_workspace = pcall(Game.IsDescendantOf, message_object, Workspace)
  7046. if success and in_workspace then
  7047. new_message_count = new_message_count + 1
  7048. new_message_list[new_message_count] = message_object
  7049. end
  7050. end
  7051. while new_message_count > ServerControl.MAX_MESSAGES do
  7052. local message_object = new_message_list[1]
  7053. Debris:AddItem(message_object, 0)
  7054. table.remove(new_message_list, 1)
  7055. new_message_count = new_message_count - 1
  7056. end
  7057. ServerControl.message_list = new_message_list
  7058. end
  7059. end
  7060. function ServerControl.FilterReplicatedStorage(child)
  7061. if child.ClassName == "RemoteEvent" and not ServerControl.authorizedRemoteEvents[child] then
  7062. Spawn(function()
  7063. child:Destroy()
  7064. Logger.printf("Info", "removed remote event %q from ReplicatedStorage", tostring(child))
  7065. end)
  7066. end
  7067. end
  7068. function ServerControl.GetPlayer(playerName)
  7069. if NetworkServer then
  7070. for _, replicator in ipairs(NetworkServer:GetChildren()) do
  7071. if replicator:IsA("NetworkReplicator") then
  7072. local player = replicator:GetPlayer()
  7073. if player and tostring(player) == playerName then
  7074. return player
  7075. end
  7076. end
  7077. end
  7078. end
  7079. end
  7080. function ServerControl.ListConnectedPlayers()
  7081. if NetworkServer then
  7082. for _, replicator in ipairs(NetworkServer:GetChildren()) do
  7083. if replicator:IsA("NetworkReplicator") then
  7084. local player = replicator:GetPlayer()
  7085. if player then
  7086. Logger.print("Output", tostring(player))
  7087. else
  7088. Logger.print("Output", "(joining)")
  7089. end
  7090. end
  7091. end
  7092. end
  7093. end
  7094. ServerControl.previous_player_list = {}
  7095. function ServerControl.MainLoop()
  7096. wait(1)
  7097. for _, player in ipairs(Players:GetChildren()) do
  7098. ypcall(function()
  7099. if player:IsA("Player") then
  7100. TaskScheduler.Schedule(ServerControl.ConnectPlayer, player)
  7101. end
  7102. end)
  7103. end
  7104. local buffer = {"AdvancedGUI.networkFrame:ClearItems()"}
  7105. local player_list = {}
  7106. local different = false
  7107. local replicator_count = 0
  7108. if NetworkServer then
  7109. for index, replicator in ipairs(NetworkServer:GetChildren()) do
  7110. if replicator:IsA("NetworkReplicator") then
  7111. local player = replicator:GetPlayer()
  7112. local item_text
  7113. if player then
  7114. local system_time, idle_time, user_name, is_nil
  7115. user_name = tostring(player)
  7116. local player_data = ServerControl.player_data[user_name]
  7117. if player_data then
  7118. system_time = player_data[1]
  7119. local idle_time_raw = player_data[2]
  7120. local seconds = idle_time_raw % 60
  7121. local minutes = (idle_time_raw - seconds) / 60
  7122. idle_time = string.format("%i:%04.1f", minutes, seconds)
  7123. else
  7124. system_time = "??:??:??"
  7125. idle_time = "?:??.?"
  7126. end
  7127. is_nil = not player.Parent
  7128. item_text = string.format("%s %s %s %s", system_time, idle_time, user_name, tostring(is_nil))
  7129. buffer[#buffer + 1] = string.format("AdvancedGUI.networkFrame:AddItem(%q, %q, %q, %s)", system_time, idle_time,
  7130.  
  7131. user_name, tostring(is_nil))
  7132. else
  7133. item_text = "(joining the game)"
  7134. buffer[#buffer + 1] = "GuiTextList.AddItem(AdvancedGUI.networkFrame, \"(joining the game)\")"
  7135. end
  7136. different = different or ServerControl.previous_player_list[index] ~= item_text
  7137. replicator_count = replicator_count + 1
  7138. player_list[index] = item_text
  7139. end
  7140. end
  7141. else
  7142. buffer[#buffer + 1] = string.format("AdvancedGUI.networkFrame:AddItem(\"<OFFLINE MODE>\")")
  7143. different = different or ServerControl.previous_player_list[1] ~= "<OFFLINE MODE>"
  7144. replicator_count = 1
  7145. player_list[1] = "<OFFLINE MODE>"
  7146. end
  7147. if different or #ServerControl.previous_player_list ~= replicator_count then
  7148. Network.TransmitController(table.concat(buffer, "\n"))
  7149. ServerControl.previous_player_list = player_list
  7150. end
  7151. end
  7152. ServerControl.connected_players = {}
  7153. ServerControl.connection_signals = {}
  7154. ServerControl.next_script_id = Network.script_id + 1
  7155. ServerControl.module_signal_packet_name = "MODULE_READY/" .. _SessionID .. "/" .. Network.server_id
  7156. function ServerControl.ConnectPlayer(player, forced)
  7157. if forced or not ServerControl.connected_players[player] then
  7158. ServerControl.connected_players[player] = 1
  7159. local valid, is_player = pcall(Game.IsA, player, "Player")
  7160. is_player = is_player == true or not valid
  7161. local is_controller = is_player and player.userId == ControllerInfo.user_id
  7162. local new_script_id
  7163. if is_controller then
  7164. new_script_id = Network.controller_id
  7165. else
  7166. new_script_id = ServerControl.next_script_id
  7167. ServerControl.next_script_id = new_script_id + 1
  7168. end
  7169. local network_receiver_script = SBTools.NewLocalScript(_SessionID .. "/" .. new_script_id, NetworkReceiver.source)
  7170. local marker_label = "ACKNOWLEDGE/" .. _SessionID .. "/" .. new_script_id
  7171. TaskScheduler.Start(function()
  7172. local connection_established = false
  7173. local listener
  7174. listener = ReplicatedStorage.ChildAdded:connect(function(child)
  7175. if child.Name == marker_label then
  7176. listener:disconnect()
  7177. local player_name = child.Value
  7178. Debris:AddItem(child, 0)
  7179. connection_established = true
  7180. Network.Register(player_name, new_script_id)
  7181. if not is_controller then
  7182. Network.TransmitController(string.format("Network.Register(%q, %s)", player_name, tostring(new_script_id)))
  7183. end
  7184. local signal = RbxUtility.CreateSignal()
  7185. ServerControl.connection_signals[new_script_id] = signal
  7186. Network.Transmit(new_script_id, string.format([[
  7187. local Module = {}
  7188. Module.name = "Module"
  7189. Module.source = %q
  7190. loadstring(Module.source)(Module)
  7191. setmetatable(Module, Module.metatable)
  7192. Module.Register(Module)
  7193. local packet = Instance.new("IntValue")
  7194. packet.Name = %q
  7195. packet.Value = %s
  7196. packet.Parent = Game:GetService("ReplicatedStorage")
  7197. ]], Module.source, ServerControl.module_signal_packet_name, tostring(new_script_id)))
  7198. signal:wait()
  7199. if ServerControl.connected_players[player] == 1 then
  7200. ServerControl.connected_players[player] = 2
  7201. ServerControl.connection_signals[new_script_id] = nil
  7202. Network.Transmit(new_script_id, "")
  7203. Network.TransmitModule(new_script_id, LuaEnum)
  7204. Network.TransmitModule(new_script_id, Logger)
  7205. Network.TransmitModule(new_script_id, Utility)
  7206. Network.TransmitModule(new_script_id, TaskScheduler)
  7207. Network.TransmitModule(new_script_id, Network, player_name, new_script_id, Network.controller_id)
  7208. if is_controller then
  7209. Network.TransmitModule(new_script_id, UserInterface, true)
  7210. Network.TransmitModule(new_script_id, PyramidCharacter)
  7211. Network.TransmitModule(new_script_id, CharacterAppearance)
  7212. Network.TransmitModule(new_script_id, PlayerControl)
  7213. Network.TransmitModule(new_script_id, ChatColor)
  7214. Network.TransmitModule(new_script_id, RBXInstance)
  7215. Network.TransmitModule(new_script_id, AdvancedGUI)
  7216. Network.TransmitModule(new_script_id, ControllerCommands)
  7217. local local_script_forward, server_script_forward
  7218. if SBTools.local_script and SBTools.server_script then
  7219. local_script_forward = SBTools.local_script:Clone()
  7220. server_script_forward = SBTools.server_script:Clone()
  7221. local_script_forward.Parent = ReplicatedStorage
  7222. server_script_forward.Parent = ReplicatedStorage
  7223. end
  7224. Network.TransmitModule(new_script_id, SBTools, local_script_forward, server_script_forward)
  7225. Network.StoreModule(new_script_id, NetworkReceiver)
  7226. Network.StoreModule(new_script_id, ChatBubble)
  7227. Network.StoreModule(new_script_id, Fragmentation)
  7228. Network.StoreModule(new_script_id, GraphicalEffects)
  7229. Network.StoreModule(new_script_id, ServerControl)
  7230. else
  7231. Network.TransmitModule(new_script_id, UserInterface)
  7232. end
  7233. Network.TransmitModule(new_script_id, Notification)
  7234. end
  7235. end
  7236. end)
  7237. repeat
  7238. if is_player then
  7239. local success, errorMessage = ypcall(function()
  7240. for _, child in ipairs(Workspace:GetChildren()) do
  7241. if Players:GetPlayerFromCharacter(child) == player then
  7242. local pscript = network_receiver_script:Clone()
  7243. pscript.Parent = child
  7244. wait()
  7245. pscript.Disabled = false
  7246. local changed_connection = pscript.Changed:connect(function(property)
  7247. if property == "Disabled" and pscript.Disabled then
  7248. wait()
  7249. pscript.Disabled = false
  7250. end
  7251. end)
  7252. wait(15)
  7253. changed_connection:disconnect()
  7254. break
  7255. end
  7256. end
  7257. end)
  7258. if not success then
  7259. Logger.printf("Severe", "Error in ServerControl.ConnectPlayer: %s", errorMessage)
  7260. end
  7261. success, errorMessage = ypcall(function()
  7262. if not (connection_established or not player.Parent) then
  7263. local pscript = network_receiver_script:Clone()
  7264. pscript.Parent = player:WaitForChild("Backpack")
  7265. wait()
  7266. pscript.Disabled = false
  7267. local changed_connection = pscript.Changed:connect(function(property)
  7268. if property == "Disabled" and pscript.Disabled then
  7269. wait()
  7270. pscript.Disabled = false
  7271. end
  7272. end)
  7273. wait(15)
  7274. changed_connection:disconnect()
  7275. end
  7276. end)
  7277. if not success then
  7278. Logger.printf("Severe", "Error in ServerControl.ConnectPlayer: %s", errorMessage)
  7279. end
  7280. else
  7281. local success, errorMessage = ypcall(function()
  7282. local pscript = network_receiver_script:Clone()
  7283. pscript.Parent = player
  7284. wait()
  7285. pscript.Disabled = false
  7286. local changed_connection = pscript.Changed:connect(function(property)
  7287. if property == "Disabled" and pscript.Disabled then
  7288. wait()
  7289. pscript.Disabled = false
  7290. end
  7291. end)
  7292. wait(15)
  7293. changed_connection:disconnect()
  7294. end)
  7295. if not success then
  7296. Logger.printf("Severe", "Error in ServerControl.ConnectPlayer: %s", errorMessage)
  7297. end
  7298. end
  7299. wait()
  7300. until connection_established or not pcall(function() assert(player.Parent) end)
  7301. end)
  7302. end
  7303. end
  7304. function ServerControl.HandleEstablishmentPacket(packet)
  7305. if tostring(packet) == ServerControl.module_signal_packet_name and packet.ClassName == "IntValue" then
  7306. local success, message = ypcall(function() ServerControl.connection_signals[packet.Value]:fire() end)
  7307. if not success then
  7308. Logger.printf("Severe", "Error in ServerControl.HandleEstablishmentPacket: %s", message)
  7309. end
  7310. Debris:AddItem(packet, 0)
  7311. end
  7312. end
  7313. function ServerControl.OnConnectionRemoving(replicator)
  7314. local player = replicator:GetPlayer()
  7315. if player then
  7316. local player_name = tostring(player)
  7317. Network.script_ids[player_name] = nil
  7318. ServerControl.player_data[player_name] = nil
  7319. end
  7320. end
  7321. function ServerControl.OnWorkspaceDescendantAdded(object)
  7322. local class_name = object.ClassName
  7323. if class_name == "Message" or class_name == "Hint" then
  7324. local success, message = ypcall(ServerControl.BlockMessageSpam, object)
  7325. if not success then
  7326. Logger.printf("Severe", "Error in ServerControl.BlockMessageSpam: %s", message)
  7327. end
  7328. end
  7329. end
  7330. function ServerControl.RemoteDisconnect(target, banish)
  7331. local targetCaseInsensitive = Utility.CaseInsensitivePattern(target)
  7332. local remoteEvent = Instance.new("RemoteEvent")
  7333. ServerControl.authorizedRemoteEvents[remoteEvent] = true
  7334. remoteEvent.Parent = ReplicatedStorage
  7335. for _, replicator in ipairs(NetworkServer:GetChildren()) do
  7336. local className = Utility.SafeGetProperty(replicator, "ClassName")
  7337. if className == "ServerReplicator" then
  7338. local player = replicator:GetPlayer()
  7339. if player then
  7340. local playerName = tostring(player)
  7341. if string.find(playerName, targetCaseInsensitive) then
  7342. Logger.printf("Info", "Disconnecting%s player %s using RemoteEvent", banish and " and banishing" or "",
  7343.  
  7344. Utility.ToString(player))
  7345. if banish then
  7346. ServerControl.BanishName(playerName)
  7347. end
  7348. remoteEvent:FireClient(player, ServerControl.LONG_STRING)
  7349. end
  7350. end
  7351. end
  7352. end
  7353. ServerControl.authorizedRemoteEvents[remoteEvent] = false
  7354. Debris:AddItem(remoteEvent, 1)
  7355. end
  7356. function ServerControl.SendConnections()
  7357. local buffer = {}
  7358. for name, id in pairs(Network.script_ids) do
  7359. if id == Network.controller_id then
  7360. buffer[#buffer + 1] = string.format("Network.script_ids[\"\"] = %s;", tostring(id))
  7361. else
  7362. buffer[#buffer + 1] = string.format("Network.script_ids[%q] = %s;", name, tostring(id))
  7363. end
  7364. end
  7365. Network.TransmitController(table.concat(buffer))
  7366. end
  7367. function ServerControl.PlayerAdded(player)
  7368. if not (ServerControl.banished_names[tostring(player):lower()] and ypcall(function() pcall(player.Kick, player) wait() pcall(Game.Destroy, player)
  7369.  
  7370. Logger.printf("Info", "Prevented player %s from entering", tostring(player)) end)) then
  7371. local success, message = ypcall(ServerControl.ConnectPlayer, player)
  7372. if not success then
  7373. Logger.printf("Severe", "Error in ServerControl.ConnectPlayer: %s", message)
  7374. end
  7375. end
  7376. end
  7377. Players.PlayerAdded:connect(function(...)
  7378. ServerControl.PlayerAdded(...)
  7379. end)
  7380. for _, player in ipairs(Players:GetChildren()) do
  7381. pcall(function()
  7382. if player:IsA("Player") then
  7383. ServerControl.ConnectPlayer(player)
  7384. end
  7385. end)
  7386. end
  7387. function ServerControl.SBScriptInject(child)
  7388. if child.ClassName == "Script" then
  7389. local value = child:WaitForChild(SBTools.source_name)
  7390. if not value or value.ClassName ~= "StringValue" then
  7391. return
  7392. end
  7393. value.Value = [[do local
  7394.  
  7395. a,b,c,d,_a,aa,ba,ca,da,_b,ab,bb,cb,db,_c,ac,bc,cc,dc,_d,ad=true,coroutine.yield,error,getfenv,pairs,rawset,setfenv,setmetatable,tonumber,type,script,Game:Ge
  7396.  
  7397. tService("ReplicatedStorage")rbx_ENV=d(1)patched=ca({},{__index=rbx_ENV})db={__index=patched,__metatable="The metatable is locked"}_c=ca({},db)function ac
  7398.  
  7399. (bd)c("The script has terminated",bd+1)end;function bc(bd)return function(...)if not a then ac(2)end;return bd(...)end end function cc(bd,cd)local
  7400.  
  7401. dd,__a=rbx_ENV[bd],{}for a_a,b_a in ipairs(cd)do __a[b_a]=bc(dd[b_a])end patched[bd]=ca({},{__metatable="The metatable is locked",__index=ca(__a,
  7402.  
  7403. {__index=dd}),__newindex=dd})end for bd,cd in ipairs
  7404.  
  7405. {"assert","delay","Delay","getmetatable","ipairs","next","pairs","pcall","print","rawequal","rawget","rawset","select","setmetatable","Spawn","tick","time",
  7406.  
  7407. "tonumber","tostring","type","unpack","wait","Wait","ypcall"}do patched[cd]=bc(rbx_ENV[cd])end for bd,cd in pairs{BrickColor=
  7408.  
  7409. {"new","palette","random"},Color3={"new"},CFrame={"Angles","fromAxisAngle","fromEulerAnglesXYZ","new"},coroutine=
  7410.  
  7411. {"create","resume","wrap","yield"},Instance={"Lock","new","Unlock"},Ray={"new"},Region3={"new"},UDim2={"new"},Vector2={"new"},Vector3=
  7412.  
  7413. {"FromAxis","FromNormalId","new"}}do cc(bd,cd)end function patched.getfenv(bd)if bd==nil then bd=1 end;local cd=_b(bd)local dd=da(bd)local __a if dd then if
  7414.  
  7415. dd>0.5 then dd=dd+1 elseif dd<-0.5 then c("bad argument #1 to 'getfenv' (level must be non-negative)",2)else dd=0 end;__a=d(dd)elseif cd=="function"then
  7416.  
  7417. __a=d(bd)else c("bad argument #1 to 'getfenv' (number expected, got "..cd..")",2)end;if __a.pairs==_a then __a=_c end;return __a end;ba(0,_c)ba
  7418.  
  7419. (1,_c)function dc(bd)if bd.Name=="__TERMINATE_SB_SCRIPTS__"and bd.ClassName=="NumberValue"and bd.Value==]].._SessionID..[[ then _d:disconnect
  7420.  
  7421. ()a=false;db.__index=nil for cd in _a(_c)do aa(_c,cd,nil)end;db.__newindex={}ba(0,{})end end;_d=bb.ChildAdded:connect
  7422.  
  7423. (dc)ad=ab.Parent.DescendantRemoving:connect(function(bd)if bd==ab then ad:disconnect()ab.Disabled=true;b()ab.Disabled=false _d:disconnect
  7424.  
  7425. ()_d=bb.ChildAdded:connect(dc)end end)end;]] .. value.Value
  7426. end
  7427. end
  7428. ReplicatedStorage.ChildAdded:connect(function(child)
  7429. ServerControl.HandleEstablishmentPacket(child)
  7430. end)
  7431. if NetworkServer then
  7432. NetworkServer.DescendantRemoving:connect(function(...)
  7433. local success, message = pcall(ServerControl.OnConnectionRemoving, ...)
  7434. if not success then
  7435. Logger.printf("Severe", "Error in ServerControl.OnConnectionRemoving: %s", message)
  7436. end
  7437. end)
  7438. end
  7439. ReplicatedStorage.ChildAdded:connect(function(...)
  7440. local success, message = pcall(ServerControl.FilterReplicatedStorage, ...)
  7441. if not success then
  7442. Logger.printf("Severe", "Error in ServerControl.FilterReplicatedStorage: %s", message)
  7443. end
  7444. end)
  7445. for _, child in ipairs(ReplicatedStorage:GetChildren()) do
  7446. local success, message = pcall(ServerControl.FilterReplicatedStorage, child)
  7447. if not success then
  7448. Logger.printf("Severe", "Error in ServerControl.FilterReplicatedStorage: %s", message)
  7449. end
  7450. end
  7451. if SBTools.server_script then
  7452. Logger.print("Info", "Enabling server script injection in ServerControl")
  7453. Workspace.ChildAdded:connect(function(child)
  7454. success, message = ypcall(ServerControl.SBScriptInject, child)
  7455. if not success then
  7456. Logger.printf("Severe", "Error in ServerControl.SBScriptInject", message)
  7457. end
  7458. end)
  7459. end
  7460. Logger.print("Info", "Enabling message spam blocker in ServerControl")
  7461. Workspace.DescendantAdded:connect(function(object)
  7462. ServerControl.OnWorkspaceDescendantAdded(object)
  7463. end)
  7464. TaskScheduler.Start(function()
  7465. while true do
  7466. ServerControl.MainLoop()
  7467. end
  7468. end)
  7469. ]=])
  7470. Module.Store("CustomSB", [[
  7471. local function PlayerAdded(player)
  7472. player.Chatted:connect(function(message)
  7473. local source
  7474. source = string.match(message, "^script/(.*)")
  7475. if source then
  7476. local script = SBTools.NewScript("QuickScript", source, Workspace)
  7477. script.Disabled = false
  7478. else
  7479. source = string.match(message, "^local/(.*)")
  7480. if source then
  7481. local script = SBTools.NewLocalScript("QuickScript", source, player:FindFirstChild("Backpack"))
  7482. script.Disabled = false
  7483. end
  7484. end
  7485. end)
  7486. end
  7487. for _, player in ipairs(Players:GetChildren()) do
  7488. pcall(PlayerAdded, player)
  7489. end
  7490. Players.PlayerAdded:connect(function(player)
  7491. pcall(PlayerAdded, player)
  7492. end)
  7493. ]])
  7494. Module.Create("ControllerCommands", [=[
  7495. ControllerCommands.altKey = "["
  7496. ControllerCommands.BALEFIRE_SPEED = 40
  7497. function ControllerCommands.BalefireAtMouse()
  7498. local head = PlayerControl.GetHead()
  7499. if head then
  7500. local target = Mouse.Hit.p
  7501. local origin = head.Position
  7502. local direction = (target - origin).unit
  7503. local explosionCount = 0
  7504. local animation_frame = 0
  7505. local magic_circle_position = origin + direction * 4
  7506. local magic_circle_cframe = CFrame.new(magic_circle_position, magic_circle_position + direction)
  7507. local magic_circle_part = Instance.new("Part")
  7508. local magic_circle_mesh = Instance.new("BlockMesh", magic_circle_part)
  7509. local magic_circle_light = Instance.new("PointLight", magic_circle_part)
  7510. local magic_circle_decal_back = Instance.new("Decal", magic_circle_part)
  7511. local magic_circle_decal_front = Instance.new("Decal", magic_circle_part)
  7512. magic_circle_part.Anchored = true
  7513. magic_circle_part.Archivable = false
  7514. magic_circle_part.BottomSurface = "Smooth"
  7515. magic_circle_part.CanCollide = false
  7516. magic_circle_part.CFrame = magic_circle_cframe
  7517. magic_circle_part.FormFactor = "Custom"
  7518. magic_circle_part.Locked = true
  7519. magic_circle_part.Size = Vector3.new(0.2, 0.2, 0.2)
  7520. magic_circle_part.TopSurface = "Smooth"
  7521. magic_circle_part.Transparency = 1
  7522. magic_circle_mesh.Scale = Vector3.new(60, 60, 0)
  7523. magic_circle_light.Color = Color3.new(1, 0.5, 1)
  7524. magic_circle_light.Range = 16
  7525. magic_circle_light.Shadows = true
  7526. magic_circle_decal_back.Face = "Back"
  7527. magic_circle_decal_back.Texture = "rbxassetid://122610943"
  7528. magic_circle_decal_front.Face = "Front"
  7529. magic_circle_decal_front.Texture = "rbxassetid://122610943"
  7530. local function NextExplosion()
  7531. explosionCount = explosionCount + 1
  7532. Instance.new("Explosion", Workspace).Position = origin + direction * (explosionCount * 8 + 4)
  7533. end
  7534. local function AnimateMagicCircle()
  7535. animation_frame = animation_frame + 1
  7536. local transparency = (animation_frame / 40) ^ 3
  7537. if animation_frame == 40 then
  7538. pcall(Game.Destroy, magic_circle_part)
  7539. else
  7540. if magic_circle_part.Parent ~= Workspace then
  7541. pcall(Utility.SetProperty, magic_circle_part, "Parent", Workspace)
  7542. end
  7543. head = PlayerControl.GetHead()
  7544. if head then
  7545. magic_circle_position = head.Position + direction * 4
  7546. end
  7547. magic_circle_part.CFrame = CFrame.new(magic_circle_position, magic_circle_position + direction) * CFrame.Angles(0, 0,
  7548.  
  7549. math.tau * animation_frame / 40 * 1.5)
  7550. magic_circle_light.Brightness = 1 - transparency
  7551. magic_circle_decal_back.Transparency = transparency
  7552. magic_circle_decal_front.Transparency = transparency
  7553. end
  7554. end
  7555. magic_circle_part.Parent = Workspace
  7556. for i = 1, 40 do
  7557. Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  7558. Delay((i - 1) / 30, AnimateMagicCircle)
  7559. end
  7560. for i = 1, 20 do
  7561. Delay((i - 1) / ControllerCommands.BALEFIRE_SPEED, NextExplosion)
  7562. end
  7563. end
  7564. end
  7565. function ControllerCommands.ControlRandomDummy()
  7566. local dummies = {}
  7567. local numDummies = 0
  7568. for _, character in ipairs(Workspace:GetChildren()) do
  7569. local name = tostring(character)
  7570. if name == "???" or name == "Dummy" then
  7571. local head, humanoid
  7572. for _, child in ipairs(character:GetChildren()) do
  7573. local className = child.ClassName
  7574. if className == "Part" and tostring(child) == "Head" then
  7575. head = child
  7576. if humanoid then
  7577. break
  7578. end
  7579. elseif className == "Humanoid" then
  7580. if child.Health > 0 then
  7581. humanoid = child
  7582. if head then
  7583. break
  7584. end
  7585. else
  7586. break
  7587. end
  7588. end
  7589. end
  7590. if head and humanoid then
  7591. numDummies = numDummies + 1
  7592. dummies[numDummies] = {character, head, humanoid}
  7593. end
  7594. end
  7595. end
  7596. if numDummies > 0 then
  7597. local dummy = dummies[math.random(numDummies)]
  7598. Player.Character = dummy[1]
  7599. Network.TransmitServer("chatAdornee = ...", dummy[2])
  7600. Camera.CameraSubject = dummy[3]
  7601. Camera.CameraType = "Track"
  7602. end
  7603. end
  7604. function ControllerCommands.Decalify(textures, exclusion)
  7605. local objects = Workspace:GetChildren()
  7606. for _, object in ipairs(objects) do
  7607. if not exclusion[object] then
  7608. for _, child in ipairs(object:GetChildren()) do
  7609. objects[#objects + 1] = child
  7610. end
  7611. if object:IsA("BasePart") then
  7612. local texture = textures[math.random(#textures)]
  7613. local face_left = Instance.new("Decal", object)
  7614. face_left.Face = Enum.NormalId.Left
  7615. face_left.Texture = texture
  7616. local face_right = Instance.new("Decal", object)
  7617. face_right.Face = Enum.NormalId.Right
  7618. face_right.Texture = texture
  7619. local face_bottom = Instance.new("Decal", object)
  7620. face_bottom.Face = Enum.NormalId.Bottom
  7621. face_bottom.Texture = texture
  7622. local face_top = Instance.new("Decal", object)
  7623. face_top.Face = Enum.NormalId.Top
  7624. face_top.Texture = texture
  7625. local face_front = Instance.new("Decal", object)
  7626. face_front.Face = Enum.NormalId.Front
  7627. face_front.Texture = texture
  7628. local face_back = Instance.new("Decal", object)
  7629. face_back.Face = Enum.NormalId.Back
  7630. face_back.Texture = texture
  7631. end
  7632. end
  7633. end
  7634. end
  7635. function ControllerCommands.EnableOfflineMode()
  7636. Network.script_ids["[SERVER]"] = Network.controller_id
  7637. Network.server_id = Network.controller_id
  7638. Module.Initialize(ChatBubble)
  7639. Module.Initialize(GraphicalEffects)
  7640. end
  7641. function ControllerCommands.ExplodeAtMouse()
  7642. local explosion = Instance.new("Explosion")
  7643. explosion.Position = Mouse.Hit.p
  7644. explosion.Parent = Workspace
  7645. end
  7646. function ControllerCommands.LaserAtMouse()
  7647. Network.TransmitServer("GraphicalEffects.ShootLaserOfDeath(...)", Mouse.Hit.p)
  7648. end
  7649. function ControllerCommands.BigLaser(target)
  7650. Network.TransmitServer("GraphicalEffects.ShootLaserOfDeath(..., {brickcolor = BrickColor.new(\"New Yeller\"), duration = 80, fragmentation_size = 6,
  7651.  
  7652. laser_scale = 30, light_color = Color3.new(1, 0.5, 0), magic_circle_image = \"rbxassetid://126561317\", magic_circle_scale = 1.5, sound_volume = 1,
  7653.  
  7654. special_effects = BrickColor.new(\"Deep orange\"), stay = 2})", target)
  7655. end
  7656. function ControllerCommands.BigLaserAtMouse()
  7657. ControllerCommands.BigLaser(Mouse.Hit.p)
  7658. end
  7659. function ControllerCommands.ShootMissile(targetPart, pointOnPart, direction)
  7660. Network.TransmitServer("GraphicalEffects.ShootMissile(...)", targetPart, pointOnPart, direction)
  7661. end
  7662. function ControllerCommands.ShootMissileAtMouse(amount, spread, delayTime)
  7663. local exclusionList = {}
  7664. local playerHead = PlayerControl.GetHead()
  7665. local playerTorso = PlayerControl.GetTorso()
  7666. if playerHead and playerTorso then
  7667. exclusionList[playerTorso] = true
  7668. local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  7669. local targetPart, pointOnPart
  7670. if humanoid and torso then
  7671. targetPart, pointOnPart = torso, Vector3.new()
  7672. else
  7673. local target = Mouse.Target
  7674. if target then
  7675. targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  7676. else
  7677. return
  7678. end
  7679. end
  7680. if targetPart then
  7681. local direction = (Mouse.Hit.p - playerHead.Position).unit
  7682. delayTime = delayTime or 0
  7683. for index = 1, amount do
  7684. local angles = math.tau * (index - 0.5) * spread / amount * Vector3.new(math.random() - 0.5, math.random() - 0.5,
  7685.  
  7686. math.random() - 0.5).unit
  7687. TaskScheduler.Schedule(delayTime * (index - 1), ControllerCommands.ShootMissile, targetPart, pointOnPart, CFrame.Angles
  7688.  
  7689. (angles.X, angles.Y, angles.Z) * direction)
  7690. end
  7691. end
  7692. end
  7693. end
  7694. function ControllerCommands.ShootMissileAroundMouse(amount, offset, delayTime)
  7695. local exclusionList = {}
  7696. local playerHead = PlayerControl.GetHead()
  7697. local playerTorso = PlayerControl.GetTorso()
  7698. if playerHead and playerTorso then
  7699. exclusionList[playerTorso] = true
  7700. local humanoid, torso = Utility.FindHumanoidClosestToRay(Mouse.UnitRay, exclusionList)
  7701. local targetPart, pointOnPart
  7702. if humanoid and torso then
  7703. targetPart, pointOnPart = torso, Vector3.new()
  7704. else
  7705. local target = Mouse.Target
  7706. if target then
  7707. targetPart, pointOnPart = target, target.CFrame:pointToObjectSpace(Mouse.Hit.p)
  7708. else
  7709. return
  7710. end
  7711. end
  7712. if targetPart then
  7713. delayTime = delayTime or 0
  7714. local index = 1
  7715. local targetPoint = targetPart.CFrame * pointOnPart
  7716. local rotation_offset_angles = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, 0).unit
  7717. local rotation_offset = CFrame.Angles(rotation_offset_angles.x, rotation_offset_angles.y, 0)
  7718. local angle_x = 0
  7719. local angle_x_step = math.tau / math.phi
  7720. for i = 1, 8 * amount do
  7721. angle_x = angle_x + angle_x_step
  7722. local direction = rotation_offset * (CFrame.Angles(0, math.tau * index / amount, 0) * CFrame.Angles(angle_x, 0,
  7723.  
  7724. 0).lookVector)
  7725. local blocked = Workspace:FindPartOnRay(Ray.new(targetPoint, direction * offset), targetPart.Parent)
  7726. if not blocked then
  7727. TaskScheduler.Schedule(delayTime * (index - 1), Network.TransmitServer, "local p0, p1, p2, p3 = ...;
  7728.  
  7729. GraphicalEffects.ShootMissile(p0, p1, p2, function() return p0 end, p3, true)", targetPart, pointOnPart, direction, offset)
  7730. index = index + 1
  7731. if index > amount then
  7732. break
  7733. end
  7734. end
  7735. end
  7736. end
  7737. end
  7738. end
  7739. local _ = string.char
  7740. function ControllerCommands.HugeExplosionOfDoom(position)
  7741. local connections = {}
  7742. local parts = {}
  7743. local cframe = CFrame.new(position)
  7744. local function ExplosionHit(part)
  7745. if part:GetMass() < 10000 and part.Parent ~= Camera then
  7746. parts[part] = true
  7747. part.Anchored = true
  7748. part:BreakJoints()
  7749. part.BrickColor = BrickColor.new("Instituational white")
  7750. end
  7751. end
  7752. for i = 1, 4 do
  7753. local quantity = 0.5 * i * (1 + i)
  7754. local fraction = math.tau / quantity
  7755. for x = 1, quantity do
  7756. for y = 1, quantity do
  7757. local explosion = Instance.new("Explosion")
  7758. connections[#connections + 1] = explosion.Hit:connect(ExplosionHit)
  7759. explosion.BlastRadius = 5
  7760. explosion.Position = cframe * (CFrame.Angles(fraction * x, fraction * y, 0) * Vector3.new((i - 1) * 6, 0, 0))
  7761. explosion.Parent = Workspace
  7762. end
  7763. end
  7764. wait(0.075)
  7765. end
  7766. for part in pairs(parts) do
  7767. for _, child in ipairs(part:GetChildren()) do
  7768. if child:IsA("BodyMover") then
  7769. child:Destroy()
  7770. end
  7771. end
  7772. local mass = part:GetMass()
  7773. local velocity = CFrame.Angles(math.tau * math.random(), math.tau * math.random(), 0) * Vector3.new(25, 0, 0)
  7774. local bodythrust = Instance.new("BodyThrust")
  7775. bodythrust.force = mass * -velocity
  7776. bodythrust.Parent = part
  7777. local bodyforce = Instance.new("BodyForce")
  7778. bodyforce.force = mass * Vector3.new(0, 196.2, 0)
  7779. bodyforce.Parent = part
  7780. part.Anchored = false
  7781. part.Reflectance = 1
  7782. part.RotVelocity = math.tau * Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5)
  7783. part.Transparency = 0.5
  7784. part.Velocity = (part.CFrame - part.Position) * velocity
  7785. end
  7786. for _, connection in ipairs(connections) do
  7787. connection:disconnect()
  7788. end
  7789. for i = 0, 99 do
  7790. Delay(i / 10, function()
  7791. for part in pairs(parts) do
  7792. local new_transparency = 0.5 * (1 + i / 50)
  7793. part.Reflectance = 0.98 * part.Reflectance
  7794. if new_transparency > part.Transparency then
  7795. part.Transparency = new_transparency
  7796. end
  7797. end
  7798. end)
  7799. end
  7800. Delay(10, function()
  7801. for part in pairs(parts) do
  7802. pcall(part.Destroy, part)
  7803. end
  7804. end)
  7805. end
  7806. function ControllerCommands.HugeExplosionOfDoomAtMouse()
  7807. ControllerCommands.HugeExplosionOfDoom(Mouse.Hit.p)
  7808. end
  7809. function ControllerCommands.PrintClosestCamera(position, timeout)
  7810. if ControllerCommands.cameraPoints then
  7811. Logger.print("Warning", "ControllerCommands.PrintClosestCamera() can only be used once at a time!")
  7812. return
  7813. end
  7814. local cameraPoints = {}
  7815. ControllerCommands.cameraPoints = cameraPoints
  7816. Network.Transmit("^[^<]", [[Network.TransmitController(string.format("local c = ControllerCommands.cameraPoints if c then c[%q] =
  7817.  
  7818. Workspace.CurrentCamera.Focus.p end", tostring(Player)))]])
  7819. Wait(timeout)
  7820. ControllerCommands.cameraPoints = nil
  7821. local minDistance, closestPlayerName = math.huge, nil
  7822. for playerName, cameraPoint in pairs(cameraPoints) do
  7823. local distance = (cameraPoint - position).magnitude
  7824. if distance < minDistance then
  7825. minDistance = distance
  7826. closestPlayerName = playerName
  7827. end
  7828. end
  7829. if closestPlayerName then
  7830. Logger.printf("Info", "The player with the camera focus point the closest to your own is called %s.", closestPlayerName)
  7831. else
  7832. Logger.print("Warning", "No camera point data was received.")
  7833. end
  7834. end
  7835. function ControllerCommands.SpaceHyperBeam(...)
  7836. Network.TransmitServer("GraphicalEffects.SpaceHyperBeam(...)", ...)
  7837. end
  7838. function ControllerCommands.SpaceHyperBeamAtMouse()
  7839. ControllerCommands.SpaceHyperBeam(Mouse.Hit.p)
  7840. end
  7841. function ControllerCommands.ConcentratedSpaceHyperBeamAtMouse()
  7842. Network.TransmitServer("local p = ...; for i = 1, 50 do GraphicalEffects.SpaceHyperBeam(p) end", Mouse.Hit.p)
  7843. end
  7844. ControllerCommands.MAX_SPACE_HYPER_BEAM_LENGTH = 20
  7845. ControllerCommands.SPACE_HYPER_BEAM_DELAY = 0.1
  7846. ControllerCommands.SPACE_HYPER_BEAM_SPACING = 20
  7847. ControllerCommands.SPACE_HYPER_BEAM_START_OFFSET = 20
  7848. function ControllerCommands.SpaceHyperBeamToMouse()
  7849. local head = PlayerControl.GetHead()
  7850. if head then
  7851. local points = {}
  7852. local target = Mouse.Hit.p
  7853. local start_offset = ControllerCommands.SPACE_HYPER_BEAM_START_OFFSET
  7854. local origin = head.CFrame * Vector3.new(0, -1.5, 0)
  7855. local distance = (target - origin) * Vector3.new(1, 0, 1)
  7856. local direction = distance.unit
  7857. local distance = distance.magnitude
  7858. local spacing = ControllerCommands.SPACE_HYPER_BEAM_SPACING
  7859. local max_distance = ControllerCommands.MAX_SPACE_HYPER_BEAM_LENGTH * spacing
  7860. if distance > max_distance then
  7861. distance = max_distance
  7862. else
  7863. distance = distance + (spacing - distance) % spacing
  7864. end
  7865. target = origin + direction * distance
  7866. for offset = 0, distance, spacing do
  7867. local part, hit_point = Workspace:FindPartOnRay(Ray.new(
  7868. origin + direction * (start_offset + offset) + Vector3.new(0, 500, 0),
  7869. Vector3.new(0, -1000, 0)
  7870. ))
  7871. points[#points + 1] = hit_point
  7872. end
  7873. Network.TransmitServer(string.format("for _, point in ipairs {...} do GraphicalEffects.SpaceHyperBeam(point) wait(%s) end", tostring
  7874.  
  7875. (ControllerCommands.SPACE_HYPER_BEAM_DELAY)), unpack(points))
  7876. end
  7877. end
  7878. function ControllerCommands.SpawnSapientRock(position)
  7879. Network.TransmitServer("GraphicalEffects.SpawnSapientRock(...)", position)
  7880. end
  7881. function ControllerCommands.SpawnSapientRockAtMouse()
  7882. ControllerCommands.SpawnSapientRock(Mouse.Hit.p)
  7883. end
  7884. function ControllerCommands.TeleportCharacterToMouse()
  7885. if PlayerControl.IsEnabled() then
  7886. local torso = PlayerControl.GetTorso()
  7887. if torso then
  7888. local pos = Mouse.Hit.p + Vector3.new(0, 5, 0)
  7889. torso.CFrame = CFrame.new(pos, pos + torso.CFrame.lookVector)
  7890. end
  7891. else
  7892. local new_focus_position = Mouse.Hit.p
  7893. local direction_vector = Camera.CoordinateFrame.lookVector
  7894. local new_focus = CFrame.new(new_focus_position, new_focus_position + direction_vector)
  7895. Camera.CoordinateFrame = new_focus * CFrame.new(0, 0, 25)
  7896. Camera.Focus = new_focus
  7897. end
  7898. end
  7899. function ControllerCommands.Reboot()
  7900. Network.TransmitServer([[
  7901. TaskScheduler.Start(function()
  7902. while true do
  7903. ChatBubble.MainLoop()
  7904. end
  7905. end)
  7906. TaskScheduler.Start(function()
  7907. while true do
  7908. GraphicalEffects.MainLoop()
  7909. end
  7910. end)
  7911. TaskScheduler.Start(function()
  7912. while true do
  7913. ServerControl.MainLoop()
  7914. end
  7915. end)
  7916. local theme = ChatBubble.GetTheme()
  7917. ChatBubble.SetTheme("Classic")
  7918. ChatBubble.Create("[REBOOT COMPLETE]")
  7919. wait(0.5)
  7920. ChatBubble.Create("[ALL SYSTEMS READY]")
  7921. ChatBubble.SetTheme(theme)
  7922. ]])
  7923. end
  7924. function ControllerCommands.ResetAdvancedGui()
  7925. GuiService:Destroy()
  7926. Module.Initialize(AdvancedGUI)
  7927. end
  7928. function ControllerCommands.FixLimbs(target)
  7929. local targetCaseInsensitive = Utility.CaseInsensitivePattern(target)
  7930. local character = PlayerControl.GetCharacter()
  7931. local user_torso = PlayerControl.GetTorso()
  7932. local objects = workspace:GetChildren()
  7933. for _, object in ipairs(objects) do
  7934. local humanoid
  7935. for _, child in ipairs(object:GetChildren()) do
  7936. objects[#objects + 1] = child
  7937. if child:IsA("Humanoid") then
  7938. humanoid = child
  7939. end
  7940. end
  7941. if humanoid and object.Name:lower():match(targetCaseInsensitive) then
  7942. local bc
  7943. for _, o in ipairs(object:GetChildren()) do
  7944. if o:IsA("BodyColors") then
  7945. bc = o
  7946. end
  7947. end
  7948. local fixing = false
  7949. local torso = object:FindFirstChild("Torso")
  7950. if torso and torso:IsA("Part") then
  7951. if not object:FindFirstChild("Left Arm") or not torso:FindFirstChild("Left Shoulder") then
  7952. fixing = true
  7953. local s = character["Left Arm"]:Clone()
  7954. local j = user_torso["Left Shoulder"]:Clone()
  7955. j.Part0 = torso
  7956. j.Part1 = s
  7957. j.CurrentAngle = 0
  7958. j.DesiredAngle = 0
  7959. j.MaxVelocity = 0
  7960. s.Anchored = true
  7961. s.BrickColor = bc and bc.LeftArmColor or BrickColor.Yellow()
  7962. local p1, r1 = s.Position, s.CFrame.lookVector
  7963. s.Parent = object
  7964. TaskScheduler.Start(function()
  7965. for i = 1, 30 do
  7966. RunService.Stepped:wait()
  7967. local a = i / 30
  7968. local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  7969. local p = p1:Lerp(c2.p, a)
  7970. s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  7971. end
  7972. s.Anchored = false
  7973. j.Parent = torso
  7974. end)
  7975. end
  7976. if not object:FindFirstChild("Right Arm") or not torso:FindFirstChild("Right Shoulder") then
  7977. fixing = true
  7978. local s = character["Right Arm"]:Clone()
  7979. local j = user_torso["Right Shoulder"]:Clone()
  7980. j.Part0 = torso
  7981. j.Part1 = s
  7982. j.CurrentAngle = 0
  7983. j.DesiredAngle = 0
  7984. j.MaxVelocity = 0
  7985. s.Anchored = true
  7986. s.BrickColor = bc and bc.RightArmColor or BrickColor.Yellow()
  7987. local p1, r1 = s.Position, s.CFrame.lookVector
  7988. s.Parent = object
  7989. TaskScheduler.Start(function()
  7990. for i = 1, 30 do
  7991. RunService.Stepped:wait()
  7992. local a = i / 30
  7993. local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  7994. local p = p1:Lerp(c2.p, a)
  7995. s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  7996. end
  7997. s.Anchored = false
  7998. j.Parent = torso
  7999. end)
  8000. end
  8001. if not object:FindFirstChild("Left Leg") or not torso:FindFirstChild("Left Hip") then
  8002. fixing = true
  8003. local s = character["Left Leg"]:Clone()
  8004. local j = user_torso["Left Hip"]:Clone()
  8005. j.Part0 = torso
  8006. j.Part1 = s
  8007. j.CurrentAngle = 0
  8008. j.DesiredAngle = 0
  8009. j.MaxVelocity = 0
  8010. s.Anchored = true
  8011. s.BrickColor = bc and bc.LeftLegColor or BrickColor.new("Br. yellowish green")
  8012. local p1, r1 = s.Position, s.CFrame.lookVector
  8013. s.Parent = object
  8014. TaskScheduler.Start(function()
  8015. for i = 1, 30 do
  8016. RunService.Stepped:wait()
  8017. local a = i / 30
  8018. local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  8019. local p = p1:Lerp(c2.p, a)
  8020. s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  8021. end
  8022. s.Anchored = false
  8023. j.Parent = torso
  8024. end)
  8025. end
  8026. if not object:FindFirstChild("Right Leg") or not torso:FindFirstChild("Right Hip") then
  8027. fixing = true
  8028. local s = character["Right Leg"]:Clone()
  8029. local j = user_torso["Right Hip"]:Clone()
  8030. j.Part0 = torso
  8031. j.Part1 = s
  8032. j.CurrentAngle = 0
  8033. j.DesiredAngle = 0
  8034. j.MaxVelocity = 0
  8035. s.Anchored = true
  8036. s.BrickColor = bc and bc.RightLegColor or BrickColor.new("Br. yellowish green")
  8037. local p1, r1 = s.Position, s.CFrame.lookVector
  8038. s.Parent = object
  8039. TaskScheduler.Start(function()
  8040. for i = 1, 30 do
  8041. RunService.Stepped:wait()
  8042. local a = i / 30
  8043. local c2 = torso.CFrame * j.C0 * j.C1:inverse()
  8044. local p = p1:Lerp(c2.p, a)
  8045. s.CFrame = CFrame.new(p, p + r1:Lerp(c2.lookVector, a))
  8046. end
  8047. s.Anchored = false
  8048. j.Parent = torso
  8049. end)
  8050. end
  8051. if fixing then
  8052. TaskScheduler.Schedule(1, function()
  8053. local anim = object:FindFirstChild("Animate")
  8054. if anim and anim.ClassName == "LocalScript" then
  8055. anim.Disabled = true
  8056. wait(0.5)
  8057. anim.Disabled = false
  8058. end
  8059. end)
  8060. end
  8061. end
  8062. end
  8063. end
  8064. end
  8065. UserInterface.SetCommand("/", Utility.ExecuteLua)
  8066. UserInterface.SetCommand("e", function(args)
  8067. local target, src = string.match(args, "%s*(%S+)(.*)")
  8068. if target then
  8069. Network.Transmit(target, src)
  8070. end
  8071. end)
  8072. UserInterface.SetCommand("s", Network.TransmitServer)
  8073. UserInterface.SetCommand("m", function(args)
  8074. local target, msg = string.match(args, "%s*(%S+)(.*)")
  8075. if target then
  8076. Network.Transmit(target, string.format("if UserInterface and UserInterface.QuickPrint then UserInterface.QuickPrint(%q .. %q) Logger.printf
  8077.  
  8078. (\"Info\", \"the private message has been received\") end", "[" .. UserInterface.player_name .. "]\t", msg))
  8079. end
  8080. end)
  8081. UserInterface.SetCommand("crash", function(target) Network.Transmit(string.match(target, "%s*(.*)"), "if Player then Utility.Crash() end") end)
  8082. UserInterface.SetCommand("givechatbar", function(target)
  8083. Network.Transmit(string.match(target, "%s*(.*)"), [[
  8084. local function LoadGui(character)
  8085. local player_gui = Player:WaitForChild("PlayerGui")
  8086. local screen_gui = Instance.new("ScreenGui")
  8087. local chat_bar = Instance.new("TextBox", screen_gui)
  8088. chat_bar.BackgroundColor3 = Color3.new(0, 0, 0)
  8089. chat_bar.BackgroundTransparency = 0.3
  8090. chat_bar.Font = "Arial"
  8091. chat_bar.FontSize = "Size18"
  8092. chat_bar.Position = UDim2.new(0, 0, 1, -20)
  8093. chat_bar.Size = UDim2.new(1, 0, 0, 22)
  8094. chat_bar.Text = "Click here to chat"
  8095. chat_bar.TextColor3 = Color3.new(1, 1, 1)
  8096. chat_bar.Changed:connect(function(property)
  8097. if property == "Text" and chat_bar.Text ~= "" then
  8098. UserInterface.Chat(chat_bar.Text)
  8099. local ChatService = Game:GetService("Chat")
  8100. ChatService:Chat(character, chat_bar.Text)
  8101. chat_bar.Text = ""
  8102. end
  8103. end)
  8104. screen_gui.Parent = player_gui
  8105. end
  8106. Player.CharacterAdded:connect(LoadGui)
  8107. LoadGui(Player.Character)
  8108. print("Gave chat bar to " .. tostring(Player))
  8109. ]])
  8110. end)
  8111. UserInterface.SetCommand("givebtools", function(args)
  8112. Network.Transmit(args:match("%s*(.*)"), "Utility.GetBuildingTools()")
  8113. end)
  8114. UserInterface.SetCommand("clean", function() Network.TransmitServer("Utility.CleanWorkspace()") end)
  8115. UserInterface.SetCommand("cleanl", function() Network.TransmitServer("Utility.CleanLighting()") end)
  8116. UserInterface.SetCommand("cleans", function() Network.TransmitServer("Utility.CleanWorkspaceAndScripts()") end)
  8117. UserInterface.SetCommand("fixlimbs", function(target) ControllerCommands.FixLimbs(target:match("%s*(.*)")) end)
  8118. ControllerCommands.FACES = {"rbxasset://textures/face.png"}
  8119. UserInterface.SetCommand("facify", function() ControllerCommands.Decalify(ControllerCommands.FACES, {[PlayerControl.GetCharacter()] = true}) end)
  8120. UserInterface.SetCommand("leave", function() Utility.Disconnect() end)
  8121. UserInterface.SetCommand("hide", function() PlayerControl.SetEnabled(false) end)
  8122. UserInterface.SetCommand("respawn", function(target)
  8123. Network.TransmitServer(string.format([[
  8124. for _, player in ipairs(Players:GetChildren()) do
  8125. if player:IsA("Player") and player.Name:match(%q) then
  8126. player:LoadCharacter()
  8127. end
  8128. end
  8129. ]], target:match("%s*(.*)")))
  8130. end)
  8131. ControllerCommands.girl_user_ids = {
  8132. 918775, -- SpleenYanks
  8133. 4112448, -- iloveroblox12
  8134. 16145046, -- pokemon275
  8135. 25321438 -- myra08
  8136. }
  8137. function ControllerCommands.SetLooks(target, appearanceId)
  8138. Network.TransmitServer(string.format([[
  8139. local appearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=%s&placeId=" .. Game.PlaceId
  8140. for _, player in ipairs(Players:GetChildren()) do
  8141. if player:IsA("Player") and player.Name:match(%q) and player.CharacterAppearance ~= appearance then
  8142. player.CharacterAppearance = appearance
  8143. player:LoadCharacter()
  8144. end
  8145. end
  8146. ]], appearanceId, target))
  8147. end
  8148. UserInterface.SetCommand("setlooks", function(args)
  8149. local target, appearanceId = string.match(args, "%s*(%S+)(.*)")
  8150. if target then
  8151. ControllerCommands.SetLooks(target, appearanceId)
  8152. end
  8153. end)
  8154. UserInterface.SetCommand("pokelooks", function(target)
  8155. Network.TransmitServer(string.format([[
  8156. local appearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=16145046&placeId=" .. game.PlaceId
  8157. for _, player in ipairs(Players:GetChildren()) do
  8158. if player:IsA("Player") and player.Name:match(%q) and player.CharacterAppearance ~= appearance then
  8159. player.CharacterAppearance = appearance
  8160. player:LoadCharacter()
  8161. end
  8162. end
  8163. ]], target:match("%s*(.*)")))
  8164. end)
  8165. UserInterface.SetCommand("makegirl", function(target)
  8166. ControllerCommands.SetLooks(target:match("%s*(.*)"), ControllerCommands.girl_user_ids[math.random(#ControllerCommands.girl_user_ids)])
  8167. end)
  8168. UserInterface.SetCommand("fixlooks", function(target)
  8169. Network.TransmitServer(string.format([[
  8170. for _, player in ipairs(Players:GetChildren()) do
  8171. if player:IsA("Player") and player.Name:match(%q) then
  8172. local appearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=" .. player.userId .. "&placeId=" .. game.PlaceId
  8173. if player.CharacterAppearance ~= appearance then
  8174. player.CharacterAppearance = appearance
  8175. player:LoadCharacter()
  8176. end
  8177. end
  8178. end
  8179. ]], target:match("%s*(.*)")))
  8180. end)
  8181. UserInterface.SetCommand("stopscripts", function()
  8182. local cmd = Instance.new("NumberValue")
  8183. cmd.Name = "__TERMINATE_SB_SCRIPTS__"
  8184. cmd.Value = _SessionID
  8185. cmd.Parent = ReplicatedStorage
  8186. Debris:AddItem(cmd, 10)
  8187. end)
  8188. local script_buffer = ""
  8189. UserInterface.SetCommand("sbuff/new", function()
  8190. script_buffer = ""
  8191. end)
  8192. UserInterface.SetCommand("sbuff/append", function(source)
  8193. script_buffer = script_buffer .. "\n" .. source:match("%s?(.*)")
  8194. end)
  8195. UserInterface.SetCommand("sbuff/runlocal", function()
  8196. Utility.ExecuteLua(script_buffer)
  8197. end)
  8198. UserInterface.SetCommand("sbuff/runserver", function()
  8199. Network.TransmitServer(script_buffer)
  8200. end)
  8201. UserInterface.SetCommand("bodyseats", function()
  8202. local torso = PlayerControl.GetTorso()
  8203. local offset1 = CFrame.Angles(0.5 * math.pi, 0, 0) * CFrame.new(0, 1.75, 0)
  8204. local offset2 = CFrame.Angles(0.5 * math.pi, 0, 0.5 * math.pi) * CFrame.new(0, 2.75, 0)
  8205. local offset3 = CFrame.Angles(0.5 * math.pi, 0, -0.5 * math.pi) * CFrame.new(0, 2.75, 0)
  8206. local seat1 = Instance.new("Seat")
  8207. seat1.BrickColor = BrickColor.new("Black")
  8208. seat1.FormFactor = "Custom"
  8209. seat1.Locked = true
  8210. seat1.Size = Vector3.new(2, 0.5, 2)
  8211. seat1.TopSurface = "Weld"
  8212. local seat2 = seat1:Clone()
  8213. local seat3 = seat1:Clone()
  8214. local joint1 = Instance.new("Weld", seat1)
  8215. local joint2 = Instance.new("Weld", seat2)
  8216. local joint3 = Instance.new("Weld", seat3)
  8217. seat1.CFrame = torso.CFrame * offset1
  8218. seat2.CFrame = torso.CFrame * offset2
  8219. seat3.CFrame = torso.CFrame * offset3
  8220. joint1.Part0 = torso
  8221. joint1.Part1 = seat1
  8222. joint1.C0 = offset1
  8223. joint2.Part0 = torso
  8224. joint2.Part1 = seat2
  8225. joint2.C0 = offset2
  8226. joint3.Part0 = torso
  8227. joint3.Part1 = seat3
  8228. joint3.C0 = offset3
  8229. seat1.Parent = Workspace
  8230. seat2.Parent = Workspace
  8231. seat3.Parent = Workspace
  8232. end)
  8233. UserInterface.SetCommand("resetcontrol", function()
  8234. Player.Character = PlayerControl.GetCharacter()
  8235. Camera.CameraSubject = PlayerControl.GetHumanoid()
  8236. Network.TransmitServer("chatAdornee = ...", PlayerControl.GetHead())
  8237. end)
  8238. UserInterface.SetCommand("controldummy", function()
  8239. ControllerCommands.ControlRandomDummy()
  8240. end)
  8241. UserInterface.SetCommand("setcharid", function(id_str)
  8242. local id = string.match(id_str, "%s*(%d+)")
  8243. if id then
  8244. id = tonumber(id)
  8245. if CharacterAppearance.stock[id] then
  8246. CharacterAppearance.defaultAppearanceId = id
  8247. else
  8248. Logger.printf("Warning", "Invalid character appearance id %s", tostring(id))
  8249. end
  8250. else
  8251. Logger.printf("Warning", "Character appearance id must be a number")
  8252. end
  8253. end)
  8254. UserInterface.SetCommand("customsb", function() Network.TransmitModule(Network.server_id, CustomSB) end)
  8255. UserInterface.SetCommand("ping", Utility.PingConnections)
  8256. UserInterface.SetCommand("ctheme", function(target) Network.TransmitServer(string.format([[ChatBubble.SetTheme(%q)]], string.match(target, "%s*(.*)"))) end)
  8257. UserInterface.SetCommand("destroy", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Utility.Destroy("Really black")]]) end)
  8258. UserInterface.SetCommand("kick", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Utility.Destroy("Really black") pcall(Game.Destroy,
  8259.  
  8260. Player)]]) end)
  8261. UserInterface.SetCommand({"banish", "ban"}, function(target) Network.Transmit(string.match(target, "%s*(.*)"), "Utility.Banish()") end)
  8262. UserInterface.SetCommand("disconnect", function(target) Network.Transmit(string.match(target, "%s*(.*)"), "Utility.Disconnect()") end)
  8263. UserInterface.SetCommand("qdc", function(target) Network.Transmit(string.match(target, "%s*(.*)"), "Utility.QuickDisconnect()") end)
  8264. UserInterface.SetCommand({"remotedisconnect", "remotedc", "rdc"}, function(target) Network.TransmitServer(string.format("ServerControl.RemoteDisconnect(%q,
  8265.  
  8266. false)", string.match(target, "%s*(.*)"))) end)
  8267. UserInterface.SetCommand({"remotebanish", "remoteban", "rban"}, function(target) Network.TransmitServer(string.format("ServerControl.RemoteDisconnect(%q,
  8268.  
  8269. true)", string.match(target, "%s*(.*)"))) end)
  8270. UserInterface.SetCommand({"copyview", "cpview"}, function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Network.TransmitController
  8271.  
  8272. ("Camera.CoordinateFrame, Camera.Focus = ...", Workspace.CurrentCamera.CoordinateFrame, Workspace.CurrentCamera.Focus) Logger.print("Info", "Copied camera
  8273.  
  8274. view")]]) end)
  8275. UserInterface.SetCommand({"closestview", "clview"}, function() ControllerCommands.PrintClosestCamera(Camera.Focus.p, 5) end)
  8276. UserInterface.SetCommand({"forcefield", "ff"}, function(target) Network.Transmit(string.match(target, "%s*(.*)"), "if Player then Instance.new(\"ForceField
  8277.  
  8278. \", Player.Character) end") end)
  8279. UserInterface.SetCommand("surround", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Utility.SurroundWithDummies(Workspace)]]) end)
  8280. UserInterface.SetCommand("lsurround", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Utility.SurroundWithDummies(Camera)]]) end)
  8281. UserInterface.SetCommand("fall", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[Utility.CreateHoleInFloor()]]) end)
  8282. UserInterface.SetCommand("jointcrap", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[if Player then Network.TransmitServer
  8283.  
  8284. ("GraphicalEffects.JointCrap(...)", Player.Character) end]]) end)
  8285. UserInterface.SetCommand("crapdance", function(target) Network.Transmit(string.match(target, "%s*(.*)"), [[if Player then Network.TransmitServer
  8286.  
  8287. ("GraphicalEffects.JointCrap(..., 0.75)", Player.Character) end]]) end)
  8288. UserInterface.SetCommand("offline", function() ControllerCommands.EnableOfflineMode() end)
  8289. UserInterface.SetCommand("reboot", function() ControllerCommands.Reboot() end)
  8290. UserInterface.SetCommand("resetgui", function() ControllerCommands.ResetAdvancedGui() end)
  8291. UserInterface.SetCommand("rejoin", function() Utility.Rejoin() end)
  8292. UserInterface.SetCommand("featherfall", function(args) PlayerControl.SetFeatherfallEnabled(not PlayerControl.IsFeatherfallEnabled()) end)
  8293. UserInterface.SetCommand("pushable", function(args) PlayerControl.SetPushable(not PlayerControl.IsPushable()) end)
  8294. UserInterface.SetCommand("rolling", function(args) PlayerControl.SetRolling(not PlayerControl.IsRolling()) end)
  8295. UserInterface.SetCommand("pyramid", function(args) PlayerControl.characterMode = PlayerControl.characterMode == "pyramid" and "normal" or "pyramid" end)
  8296. UserInterface.SetCommand("setname", function(args) UserInterface.player_name = args:match("%s*(.*)") end)
  8297. UserInterface.SetCommand("show", function() PlayerControl.SetEnabled(true) end)
  8298. UserInterface.SetCommand("shutdown", function() Network.TransmitServer([[Players.PlayerAdded:connect(function(player) pcall(function() player:Kick() end)
  8299.  
  8300. pcall(function() player.CharacterAdded:connect(function() player.Character = nil end) end) pcall(Game.Destroy, player) coroutine.yield() pcall(Game.Destroy,
  8301.  
  8302. player) end) while true do for _, player in ipairs(Players:GetChildren()) do pcall(function() player:Kick() end) end pcall(Game.ClearAllChildren, Players)
  8303.  
  8304. Network.Transmit("^[^<]", "Utility.QuickDisconnect()") coroutine.yield() end]]) end)
  8305. UserInterface.SetCommand("who", function() Network.TransmitServer("ServerControl.ListConnectedPlayers()") end)
  8306. UserInterface.SetCommand("whoc", function() Network.Transmit("^[^<]", "Logger.print(\"Output\", tostring(Player.Character))") end)
  8307. UserInterface.SetCommand("mute", function(target)
  8308. Network.Transmit(string.match(target, "%s*(.*)"), "Game:GetService(\"StarterGui\"):SetCoreGuiEnabled(4, false)")
  8309. end)
  8310. UserInterface.SetCommand("unmute", function(target)
  8311. Network.Transmit(string.match(target, "%s*(.*)"), "Game:GetService(\"StarterGui\"):SetCoreGuiEnabled(4, true)")
  8312. end)
  8313. UserInterface.SetHotkey("z", ControllerCommands.TeleportCharacterToMouse)
  8314. UserInterface.SetHotkey("c", function()
  8315. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8316. ControllerCommands.HugeExplosionOfDoomAtMouse()
  8317. else
  8318. ControllerCommands.ExplodeAtMouse()
  8319. end
  8320. end)
  8321. UserInterface.SetHotkey("j", function()
  8322. local target = Mouse.Target
  8323. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8324. Network.TransmitServer("chatAdornee = ...", target)
  8325. else
  8326. Logger.printf("Info", "The mouse is hovering over %s", Utility.ToString(target))
  8327. end
  8328. end)
  8329. UserInterface.SetHotkey("v", function()
  8330. ControllerCommands.BalefireAtMouse()
  8331. end)
  8332. UserInterface.SetHotkey("l", function()
  8333. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8334. ControllerCommands.BigLaserAtMouse()
  8335. else
  8336. local active = true
  8337. local connection = Mouse.KeyUp:connect(function(key)
  8338. if key == "l" then
  8339. active = false
  8340. end
  8341. end)
  8342. ControllerCommands.LaserAtMouse()
  8343. wait(0.5)
  8344. while active do
  8345. ControllerCommands.LaserAtMouse()
  8346. wait(1 / 6)
  8347. end
  8348. connection:disconnect()
  8349. end
  8350. end)
  8351. UserInterface.SetHotkey("b", function()
  8352. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8353. ControllerCommands.SpaceHyperBeamToMouse()
  8354. else
  8355. ControllerCommands.SpaceHyperBeamAtMouse()
  8356. end
  8357. end)
  8358. UserInterface.SetHotkey("p", function()
  8359. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8360. -- ControllerCommands.ShootMissileAtMouse(7, 0.05, 1 / 7)
  8361. ControllerCommands.ShootMissileAroundMouse(19, 50, 1 / 19)
  8362. else
  8363. ControllerCommands.ShootMissileAtMouse(1, 0, 0)
  8364. end
  8365. end)
  8366. UserInterface.SetHotkey("k", function()
  8367. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8368. ControllerCommands.ControlRandomDummy()
  8369. -- Network.TransmitServer("chatAdornee = ...", Mouse.Target)
  8370. else
  8371. local look_point = Camera.Focus.p
  8372. local torso_position = Mouse.Hit.p + Vector3.new(0, 5, 0)
  8373. local dummy = Utility.CreateDummy(CFrame.new(torso_position, Vector3.new(look_point.X, torso_position.Y, look_point.Z)), "???", Workspace)
  8374. if UserInterface.IsKeyDown("x") then
  8375. ControllerCommands.ActivateTelekinesis(dummy:FindFirstChild("Torso"))
  8376. end
  8377. end
  8378. end)
  8379. UserInterface.SetHotkey(";", function()
  8380. local target_part = Mouse.Target
  8381. if target_part then
  8382. Network.TransmitServer("ServerControl.ConnectPlayer(...)", target_part, UserInterface.IsKeyDown(ControllerCommands.altKey))
  8383. end
  8384. end)
  8385. do
  8386. local activated = false
  8387. local connection
  8388. local nodes
  8389. local function AddNode()
  8390. local target = Mouse.Target
  8391. if target then
  8392. local point = target.CFrame:inverse() * Mouse.Hit.p
  8393. local start = time()
  8394. Mouse.Button1Up:wait()
  8395. local elapsed = time() - start
  8396. for i = 0, elapsed, 0.125 do
  8397. nodes[#nodes + 1] = {target, Vector3.new(math.random() - 0.5, math.random() - 0.5, math.random() - 0.5).unit * (1 + i * 15) + point}
  8398. end
  8399. end
  8400. end
  8401. UserInterface.SetHotkey("m", function()
  8402. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8403. if activated and not deactivating then
  8404. connection:disconnect()
  8405. connection = nil
  8406. nodes = nil
  8407. activated = false
  8408. end
  8409. else
  8410. if activated then
  8411. if #nodes >= 3 then
  8412. nodes[1] = nodes[#nodes]
  8413. nodes[#nodes + 1] = nodes[2]
  8414. nodes[#nodes + 1] = nodes[3]
  8415. local buffer = {}
  8416. for index, node in ipairs(nodes) do
  8417. local point = node[1].CFrame * node[2]
  8418. buffer[index] = "Vector3.new(" .. tostring(point) .. ")"
  8419. end
  8420. Network.TransmitServer("GraphicalEffects.DestructionSpell {" .. table.concat(buffer, ",") .. "}")
  8421. elseif #nodes == 2 then
  8422. local part = nodes[1][1]
  8423. pcall(part.Destroy, part)
  8424. end
  8425. connection:disconnect()
  8426. connection = nil
  8427. nodes = nil
  8428. activated = false
  8429. else
  8430. activated = true
  8431. nodes = {false}
  8432. connection = Mouse.Button1Down:connect(AddNode)
  8433. end
  8434. end
  8435. end)
  8436. end
  8437. UserInterface.SetHotkey("n", function()
  8438. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8439. else
  8440. ControllerCommands.telekinesis_target = Mouse.Target
  8441. end
  8442. end)
  8443. function ControllerCommands.ActivateTelekinesis(part)
  8444. if part then
  8445. local removedItems = {}
  8446. for _, child in ipairs(part:GetChildren()) do
  8447. if child:IsA("BodyMover") then
  8448. removedItems[#removedItems + 1] = child
  8449. child.Parent = nil
  8450. end
  8451. end
  8452. local damage_debounce = {}
  8453. local mass = part:GetMass()
  8454. local gripDistance = (Mouse.Origin.p - Mouse.Hit.p).magnitude
  8455. local connection = part.Touched:connect(function(hit)
  8456. if UserInterface.IsKeyDown("n") then
  8457. local joint_name
  8458. if hit.Name == "Torso" then
  8459. local joint_name = ({
  8460. ["Head"] = "Neck",
  8461. ["Left Arm"] = "Left Shoulder",
  8462. ["Left Leg"] = "Left Hip",
  8463. ["Right Arm"] = "Right Shoulder",
  8464. ["Right Leg"] = "Right Hip"
  8465. })[part.Name]
  8466. end
  8467. local joint
  8468. if joint_name then
  8469. joint = Instance.new("Motor")
  8470. joint.Name = joint_name
  8471. local hit_parent = hit.Parent
  8472. if hit_parent then
  8473. TaskScheduler.Schedule(1, function()
  8474. local anim = hit.Parent:FindFirstChild("Animate")
  8475. if anim and anim.ClassName == "LocalScript" then
  8476. anim.Disabled = true
  8477. wait(0.5)
  8478. anim.Disabled = false
  8479. end
  8480. end)
  8481. end
  8482. else
  8483. joint = Instance.new("Weld")
  8484. end
  8485. local center = CFrame.new((hit.Position + part.Position) * 0.5)
  8486. joint.C0 = hit.CFrame:toObjectSpace(center)
  8487. joint.C1 = part.CFrame:toObjectSpace(center)
  8488. joint.Part0 = hit
  8489. joint.Part1 = part
  8490. joint.Parent = hit
  8491. part.Velocity = Vector3.new()
  8492. end
  8493. local character = PlayerControl.GetCharacter()
  8494. if not hit.Anchored and hit.CanCollide and not (character and hit:IsDescendantOf(character)) then
  8495. local hit_model = hit
  8496. local hit_humanoid
  8497. while hit_model and hit_model.Parent ~= workspace do
  8498. hit_model = hit_model.Parent
  8499. end
  8500. if hit_model and hit_model:IsA("Model") then
  8501. for _, child in ipairs(hit_model:GetChildren()) do
  8502. if child:IsA("Humanoid") then
  8503. hit_humanoid = child
  8504. break
  8505. end
  8506. end
  8507. end
  8508. local speed_diff = (part.Velocity - hit.Velocity).magnitude
  8509. if hit_humanoid then
  8510. if not damage_debounce[hit_humanoid] and hit.Velocity.magnitude > 100 and speed_diff >= 100 then
  8511. local damage = 0.75 * speed_diff
  8512. damage_debounce[hit_humanoid] = true
  8513. hit_humanoid:TakeDamage(damage)
  8514. wait(2)
  8515. damage_debounce[hit_humanoid] = nil
  8516. end
  8517. else
  8518. if speed_diff * speed_diff > hit:GetMass() then
  8519. hit:BreakJoints()
  8520. end
  8521. end
  8522. end
  8523. end)
  8524. local bodyPosition = Instance.new("BodyPosition", part)
  8525. bodyPosition.maxForce = Vector3.new(1e6, 1e6, 1e6) * mass
  8526. while UserInterface.IsKeyDown("x") do
  8527. if UserInterface.IsKeyDown("f") then
  8528. gripDistance = gripDistance * 1.033 + 2
  8529. end
  8530. if UserInterface.IsKeyDown("g") then
  8531. gripDistance = gripDistance / 1.033 - 2
  8532. end
  8533. local targetPosition
  8534. local targetPart = ControllerCommands.telekinesis_target
  8535. if UserInterface.IsKeyDown(ControllerCommands.altKey) and targetPart then
  8536. targetPosition = targetPart.Position
  8537. targetPosition = targetPosition + (targetPosition - part.Position).unit * 100
  8538. --bodyPosition.maxForce = Vector3.new(2e6, 2e6, 2e6)
  8539. else
  8540. targetPosition = Mouse.Origin.p + Mouse.Hit.lookVector * gripDistance
  8541. --bodyPosition.maxForce = Vector3.new(1e6, 1e6, 1e6)
  8542. end
  8543. bodyPosition.position = targetPosition
  8544. RunService.Stepped:wait()
  8545. end
  8546. for _, child in ipairs(removedItems) do
  8547. pcall(Utility.SetProperty, child, "Parent", part)
  8548. end
  8549. part:MakeJoints()
  8550. Debris:AddItem(bodyPosition, 0)
  8551. TaskScheduler.Schedule(3, function() connection:disconnect() end)
  8552. end
  8553. end
  8554. UserInterface.SetHotkey("x", function()
  8555. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8556. ControllerCommands.telekinesis_target = Mouse.Target
  8557. else
  8558. ControllerCommands.ActivateTelekinesis(Mouse.Target)
  8559. end
  8560. end)
  8561. UserInterface.SetHotkey("u", function()
  8562. if UserInterface.IsKeyDown(ControllerCommands.altKey) then
  8563. ControllerCommands.SpawnSapientRockAtMouse()
  8564. else
  8565. local part = Instance.new("Part", workspace)
  8566. local size = 8 + math.random() * 5
  8567. part.BottomSurface = "Smooth"
  8568. part.TopSurface = "Smooth"
  8569. part.Material = "Slate"
  8570. part.Shape = "Ball"
  8571. part.Size = Vector3.new(size, size, size)
  8572. part.Position = Mouse.Hit.p
  8573. if UserInterface.IsKeyDown("x") then
  8574. ControllerCommands.ActivateTelekinesis(part)
  8575. end
  8576. end
  8577. end)
  8578. UserInterface.SetHotkey("]", function()
  8579. local target = Mouse.Target
  8580. if target then
  8581. target:BreakJoints()
  8582. end
  8583. end)
  8584. shared.Chat = UserInterface.Chat
  8585. if Network.server_id then
  8586. Network.TransmitServer("ServerControl.SendConnections()")
  8587. end
  8588. ]=])
  8589. Module.Create("LaunchServer", [==[
  8590. UserInterface.SetCommand("stopservercontrol", function() Network.TransmitServer("ServerControl = {}") end) -- for emergencies
  8591. if Player.Parent then
  8592. Player:Destroy()
  8593. Player.Character = nil
  8594. end
  8595. Logger.print("Info", "Waiting for cross-network scripting in LaunchServer")
  8596. SBTools.WaitForScriptReady()
  8597. Logger.print("Info", "Cross-network scripting is ready in LaunchServer")
  8598. local server_script = SBTools.NewScript(_SessionID .. "/" .. Network.server_id, NetworkReceiver.source, Workspace)
  8599. wait(0.5)
  8600. server_script.Disabled = false
  8601. local signal_name = "MODULE_READY/" .. _SessionID .. "/" .. Network.controller_id
  8602. Network.TransmitServer(string.format([=[
  8603. local Module = {}
  8604. Module.name = "Module"
  8605. Module.source = %q
  8606. loadstring(Module.source)(Module)
  8607. setmetatable(Module, Module.metatable)
  8608. Module.Register(Module)
  8609. Module.Create("ControllerInfo", [[
  8610. ControllerInfo.user_id = %d
  8611. ]])
  8612. local packet = Instance.new("IntValue")
  8613. packet.Name = %q
  8614. packet.Parent = Game:GetService("ReplicatedStorage")
  8615. ]=], Module.source, Player.userId, signal_name))
  8616. local connection
  8617. connection = ReplicatedStorage.ChildAdded:connect(function(child)
  8618. if child.Name == signal_name then
  8619. Logger.print("Info", "Received start-up signal from server in LaunchServer")
  8620. connection:disconnect()
  8621. Network.TransmitModule(Network.server_id, LuaEnum)
  8622. Network.TransmitModule(Network.server_id, Logger)
  8623. local local_script_forward, server_script_forward
  8624. if SBTools.local_script and SBTools.server_script then
  8625. local_script_forward = SBTools.local_script:Clone()
  8626. server_script_forward = SBTools.server_script:Clone()
  8627. local_script_forward.Parent = ReplicatedStorage
  8628. server_script_forward.Parent = ReplicatedStorage
  8629. end
  8630. Network.TransmitModule(Network.server_id, SBTools, local_script_forward, server_script_forward)
  8631. Network.TransmitModule(Network.server_id, Utility)
  8632. Network.TransmitModule(Network.server_id, TaskScheduler)
  8633. Network.TransmitModule(Network.server_id, Network, "<SERVER>", Network.server_id, Network.controller_id)
  8634. Network.StoreModule(Network.server_id, NetworkReceiver)
  8635. Network.StoreModule(Network.server_id, UserInterface)
  8636. Network.StoreModule(Network.server_id, Notification)
  8637. Network.TransmitModule(Network.server_id, Serializer)
  8638. Network.TransmitModule(Network.server_id, ServerControl)
  8639. Network.TransmitModule(Network.server_id, ChatBubble)
  8640. Network.TransmitModule(Network.server_id, Fragmentation)
  8641. Network.TransmitModule(Network.server_id, GraphicalEffects)
  8642. Network.StoreModule(Network.server_id, ChatColor)
  8643. Network.StoreModule(Network.server_id, PyramidCharacter)
  8644. Network.StoreModule(Network.server_id, CharacterAppearance)
  8645. Network.StoreModule(Network.server_id, PlayerControl)
  8646. Network.StoreModule(Network.server_id, RBXInstance)
  8647. Network.StoreModule(Network.server_id, AdvancedGUI)
  8648. Network.StoreModule(Network.server_id, ControllerCommands)
  8649. Debris:AddItem(child, 0)
  8650. end
  8651. end)
  8652. ]==])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement