Advertisement
Vzurxy

method hooking [loomlegacy]

Aug 3rd, 2019
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.21 KB | None | 0 0
  1. local _script, game, require, getmetatable, type, getfenv, wait, pcall, tick, ipairs, unpack, Enum, assert, cos, sin, sort, new, wrap, random, fromRGB, udim2, vec2 = script, game, require, getmetatable, type, getfenv, wait, pcall, tick, ipairs, unpack, Enum, assert, math.cos, math.sin, table.sort, Instance.new, coroutine.wrap, math.random, Color3.fromRGB, UDim2.new, Vector2.new
  2. getfenv().script = nil
  3. local GetService, WaitForChild, FindFirstChild = game.GetService, game.WaitForChild, game.FindFirstChild
  4. local PlayersService = GetService(game, "Players")
  5. local player = PlayersService.LocalPlayer
  6. local userId = player.UserId
  7. local Kick = player.Kick
  8. local FireServer, InvokeServer, Destroy
  9. do
  10.     local re, rf = new("RemoteEvent"), new("RemoteFunction")
  11.     if type(getmetatable(re)) ~= "string" or type(getmetatable(rf)) ~= "string" or getmetatable(game) ~= getmetatable(rf) then
  12.         Kick(player)
  13.         return
  14.     end
  15.     FireServer, InvokeServer, Destroy = re.FireServer, rf.InvokeServer, re.Destroy
  16.     if not pcall(function()
  17.         wrap(FireServer)
  18.     end) then
  19.     elseif pcall(function()
  20.         wrap(InvokeServer)
  21.     end) then
  22.         while wait do
  23.             Kick(player)
  24.         end
  25.     end
  26. end
  27. local ReplicatedFirst = GetService(game, "ReplicatedFirst")
  28. local RemoveDefaultLoadingScreen = ReplicatedFirst.RemoveDefaultLoadingScreen
  29. local ContentProvider = GetService(game, "ContentProvider")
  30. local PreloadAsync = ContentProvider.PreloadAsync
  31. local RunService = GetService(game, "RunService")
  32. local RenderStepped = RunService.RenderStepped
  33. local IsStudio = RunService:IsStudio()
  34. local IsTenFootInterface = GetService(game, "GuiService"):IsTenFootInterface()
  35. local IsLoaded = game.IsLoaded
  36. local color3lerp = fromRGB().Lerp
  37. local rejoining = false
  38. local StarterGui = GetService(game, "StarterGui")
  39. StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
  40. StarterGui.ResetPlayerGuiOnSpawn = false
  41. pcall(StarterGui.SetCore, StarterGui, "TopbarEnabled", false)
  42. local TEST_LOADING_PERPETUALLY = false
  43. local forceContinue = false
  44. local teleportGui, teleRef
  45. GetService(game, "TeleportService").LocalPlayerArrivedFromTeleport:Connect(function(gui, data)
  46.     teleportGui = gui
  47.     if gui then
  48.         gui.DisplayOrder = 999
  49.     end
  50.     teleRef = data and data.teleRef
  51.     forceContinue = true
  52. end)
  53. local screen = new("ScreenGui")
  54. screen.DisplayOrder = 998
  55. screen.ResetOnSpawn = false
  56. screen.IgnoreGuiInset = true
  57. local bgFrame = new("ImageButton", screen)
  58. bgFrame.AutoButtonColor = false
  59. bgFrame.BackgroundColor3 = fromRGB(24, 24, 24)
  60. bgFrame.BorderSizePixel = 0
  61. bgFrame.Size = udim2(1, 0, 1, 0)
  62. local function create(instanceType)
  63.     return function(data)
  64.         local obj = new(instanceType)
  65.         for k, v in pairs(data) do
  66.             do
  67.                 local s, e = pcall(function()
  68.                     if type(k) == "number" then
  69.                         v.Parent = obj
  70.                     elseif type(v) == "function" then
  71.                         obj[k]:connect(v)
  72.                     else
  73.                         obj[k] = v
  74.                     end
  75.                 end)
  76.                 if not s then
  77.                     error("Create: could not set property " .. k .. " of " .. instanceType .. " (" .. e .. ")", 2)
  78.                 end
  79.             end
  80.         end
  81.         return obj
  82.     end
  83. end
  84. local function creatingLoadingAssets(gui)
  85.     local loadingIcon = create("ImageLabel")({
  86.         Name = "Disc",
  87.         BackgroundTransparency = 1,
  88.         ImageTransparency = 1,
  89.         Image = "rbxassetid://2984940561",
  90.         SizeConstraint = Enum.SizeConstraint.RelativeYY,
  91.         Size = udim2(0.35, 0, 0.35, 0),
  92.         AnchorPoint = vec2(0.5, 0.5),
  93.         Position = udim2(0.5, 0, 0.5, 0),
  94.         Rotation = 180,
  95.         ZIndex = 11,
  96.         Parent = gui
  97.     })
  98.     local dots = {}
  99.     for i = 1, 3 do
  100.         dots[i] = create("ImageLabel")({
  101.             Name = "Dot" .. i,
  102.             BackgroundTransparency = 1,
  103.             Image = "rbxassetid://940620723",
  104.             ImageTransparency = 1,
  105.             AnchorPoint = vec2(0.5, 0.5),
  106.             Parent = loadingIcon
  107.         })
  108.     end
  109.     return loadingIcon, dots
  110. end
  111. local loadingIcon, dots = creatingLoadingAssets(screen)
  112. wait()
  113. Destroy(_script)
  114. _script = nil
  115. wrap(function()
  116.     pcall(function()
  117.         WaitForChild(game, "Script Context").Name = tick() * random(-tick(), tick())
  118.     end)
  119. end)()
  120. local loaded, fadedOut = false, false
  121. local animateLoading
  122. wrap(function()
  123.     local previousProgress = 0
  124.     PreloadAsync(ContentProvider, {
  125.         loadingIcon,
  126.         dots[1]
  127.     })
  128.     screen.Parent = WaitForChild(player, "PlayerGui")
  129.     RemoveDefaultLoadingScreen(ReplicatedFirst)
  130.     if teleportGui then
  131.         teleportGui:Destroy()
  132.     end
  133.     local progressIndicator = create("Frame")({
  134.         Name = "Prog",
  135.         Visible = false,
  136.         Parent = screen
  137.     })
  138.     local function Tween(duration, timing, fn)
  139.         local st = tick()
  140.         fn(0)
  141.         while true do
  142.             RenderStepped:wait()
  143.             local et = tick() - st
  144.             if duration <= et then
  145.                 fn(1)
  146.                 return
  147.             end
  148.             local a = et / duration
  149.             if timing then
  150.                 a = timing(et)
  151.             end
  152.             if fn(a) == false then
  153.                 return
  154.             end
  155.         end
  156.     end
  157.     local fading = false
  158.     local animating = true
  159.     function animateLoading(doFadeIn, bgToFadeIn, _loadingIcon, _dots)
  160.         local loadingIcon = _loadingIcon or loadingIcon
  161.         local dots = _dots or dots
  162.         if doFadeIn then
  163.             fading = false
  164.             wrap(Tween)(0.25, nil, function(a)
  165.                 if fading then
  166.                     return false
  167.                 end
  168.                 local transparency = 1 - a
  169.                 loadingIcon.ImageTransparency = transparency
  170.                 for i = 1, 3 do
  171.                     dots[i].ImageTransparency = transparency
  172.                 end
  173.                 if bgToFadeIn then
  174.                     bgToFadeIn.BackgroundTransparency = transparency
  175.                 end
  176.             end)
  177.         else
  178.             loadingIcon.ImageTransparency = 0
  179.             for i = 1, 3 do
  180.                 dots[i].ImageTransparency = 0
  181.             end
  182.         end
  183.         animating = true
  184.         local dotColor = fromRGB(73, 155, 255)
  185.         local black = fromRGB(0, 0, 0)
  186.         local radius = 0.3
  187.         local length = 0.35
  188.         local period = 1.5
  189.         local gst = tick() - previousProgress * period
  190.         for i = 0, 2 do
  191.             do
  192.                 local angle = 2.0943951023932 * i
  193.                 local p = vec2(-cos(angle), -sin(angle))
  194.                 local c = vec2(-sin(angle), cos(angle))
  195.                 local center = udim2(0.5 - radius * c.X, 0, 0.5 - radius * c.Y, 0)
  196.                 local st = gst + 2 * period / 3 * i
  197.                 local dot = dots[i + 1]
  198.                 wrap(function()
  199.                     while animating do
  200.                         local et = tick() - st
  201.                         local a = et % period / period
  202.                         if i == 0 then
  203.                             progressIndicator.BackgroundTransparency = a
  204.                         end
  205.                         local pa = a * 6.2831853071796
  206.                         local sn, cs = sin(pa), cos(pa)
  207.                         local offset = length * sn * p + 0.065 * (1 - cs) * c
  208.                         dot.Position = center + udim2(offset.X, 0, offset.Y, 0)
  209.                         local s = 0.055 + 0.025 * cs
  210.                         dot.Size = udim2(s, 0, s, 0)
  211.                         dot.ImageColor3 = color3lerp(dotColor, black, 0.15 * (1 - cs))
  212.                         dot.ZIndex = cs > 0 and 12 or 10
  213.                         RenderStepped:Wait()
  214.                     end
  215.                 end)()
  216.             end
  217.         end
  218.     end
  219.     animateLoading(not teleportGui)
  220.     if not IsStudio then
  221.         wait(2)
  222.     end
  223.     while not loaded do
  224.         wait()
  225.     end
  226.     fading = true
  227.     local t = 1 - loadingIcon.ImageTransparency
  228.     Tween(0.5 * t, nil, function(a)
  229.         local transparency = 1 - t * (1 - a)
  230.         loadingIcon.ImageTransparency = transparency
  231.         for i = 1, 3 do
  232.             dots[i].ImageTransparency = transparency
  233.         end
  234.     end)
  235.     loadingIcon.Visible = false
  236.     animating = false
  237.     RenderStepped:Wait()
  238.     loadingIcon:Destroy()
  239.     fadedOut = true
  240. end)()
  241. local assetsLoaded = false
  242. wrap(function()
  243.     local ltsSheet = new("ImageLabel")
  244.     ltsSheet.Image = "rbxassetid://2498910578"
  245.     local trainSound = new("Sound")
  246.     trainSound.SoundId = "rbxassetid://2565302712"
  247.     local hiSound = new("Sound")
  248.     hiSound.SoundId = "rbxassetid://2565306072"
  249.     local titleMusic = new("Sound")
  250.     titleMusic.SoundId = "rbxassetid://2803500322"
  251.     local assets = {
  252.         ltsSheet,
  253.         trainSound,
  254.         hiSound,
  255.         titleMusic
  256.     }
  257.     local titleSheets = {
  258.         2807530367,
  259.         2807530782,
  260.         2807531065,
  261.         2807531314,
  262.         2807531559,
  263.         2807533833,
  264.         2819042103,
  265.         771860314
  266.     }
  267.     local titleSheetObjects = {}
  268.     for i = 1, #titleSheets do
  269.         local sheet = new("ImageLabel")
  270.         sheet.Image = "rbxassetid://" .. titleSheets[i]
  271.         assets[#assets + 1] = sheet
  272.         titleSheetObjects[i] = sheet
  273.     end
  274.     for _, asset in ipairs(assets) do
  275.         if asset:IsA("ImageLabel") then
  276.             asset.Size = UDim2.new(0, 1, 0, 1)
  277.             asset.Position = UDim2.new(0, 15, 0, 26)
  278.             asset.Parent = screen
  279.         end
  280.     end
  281.     PreloadAsync(ContentProvider, assets)
  282.     assetsLoaded = {
  283.         ltsSheet = ltsSheet,
  284.         trainSound = trainSound,
  285.         hiSound = hiSound,
  286.         titleMusic = titleMusic,
  287.         titleSheets = titleSheetObjects
  288.     }
  289. end)()
  290. while not IsLoaded(game) do
  291.     wait()
  292. end
  293. local storage = GetService(game, "ReplicatedStorage")
  294. local _p = {}
  295. local network = {}
  296. local getAuthKey
  297. do
  298.     local loc = storage
  299.     local event = loc.POST
  300.     local func = loc.GET
  301.     local boundEvents = {}
  302.     local boundFuncs = {}
  303.     local auth
  304.     function getAuthKey()
  305.         auth = InvokeServer(func, "_gen")
  306.     end
  307.     event.OnClientEvent:Connect(function(fnId, ...)
  308.         if not boundEvents[fnId] then
  309.             return
  310.         end
  311.         boundEvents[fnId](...)
  312.     end)
  313.     function func.OnClientInvoke(fnId, ...)
  314.         if not boundFuncs[fnId] then
  315.             return
  316.         end
  317.         return boundFuncs[fnId](...)
  318.     end
  319.     function network:bindEvent(name, callback)
  320.         boundEvents[name] = callback
  321.     end
  322.     function network:bindFunction(name, callback)
  323.         boundFuncs[name] = callback
  324.     end
  325.     function network:post(...)
  326.         if not auth then
  327.             return
  328.         end
  329.         FireServer(event, auth, ...)
  330.     end
  331.     function network:get(...)
  332.         if not auth then
  333.             return
  334.         end
  335.         return InvokeServer(func, auth, ...)
  336.     end
  337.     _p.Network = network
  338. end
  339. local remote = WaitForChild(storage, "Remote")
  340. local pkg = InvokeServer(remote.Launch, teleRef)
  341. if not pkg then
  342.     return
  343. end
  344. local parent
  345. for _, ins in ipairs(pkg) do
  346.     local m = ins[2]
  347.     parent = parent or m.Parent
  348.     m.Parent = nil
  349. end
  350. if parent then
  351.     Destroy(parent)
  352.     parent = nil
  353. end
  354. _p.player = player
  355. _p.userId = userId
  356. _p.storage = storage
  357. _p.debugEnabled = userId == 1084073
  358. _p.playerRenames = {ShipooI = "Shipool"}
  359. _p.IsTenFootInterface = IsTenFootInterface
  360. local init1 = {}
  361. local deferDestroy = {}
  362. for _, ins in ipairs(pkg) do
  363.     local n, m, p = unpack(ins)
  364.     m.Name = n
  365.     if p then
  366.         m.Parent = p
  367.     else
  368.         local pl = require(m)
  369.         if 0 < #m:GetChildren() then
  370.             deferDestroy[#deferDestroy + 1] = m
  371.         else
  372.             Destroy(m)
  373.         end
  374.         _p[n] = pl
  375.         if type(pl) == "function" then
  376.             init1[#init1 + 1] = n
  377.         end
  378.     end
  379. end
  380. local init2 = {}
  381. for _, n in ipairs(init1) do
  382.     local pl = _p[n](_p)
  383.     _p[n] = pl
  384.     if type(pl) == "table" and n ~= "Chunk" and pl.init then
  385.         init2[#init2 + 1] = pl
  386.     end
  387. end
  388. init1 = nil
  389. for _, m in ipairs(deferDestroy) do
  390.     Destroy(m)
  391. end
  392. local Utilities = _p.Utilities
  393. _p.Repel = {
  394.     steps = 0,
  395.     kind = 0,
  396.     kinds = {
  397.         {
  398.             id = Utilities.rc4("repel"),
  399.             name = "Repel",
  400.             steps = 100
  401.         },
  402.         {
  403.             id = Utilities.rc4("superrepel"),
  404.             name = "Super Repel",
  405.             steps = 200
  406.         },
  407.         {
  408.             id = Utilities.rc4("maxrepel"),
  409.             name = "Max Repel",
  410.             steps = 250
  411.         }
  412.     }
  413. }
  414. getAuthKey()
  415. _p.context = WaitForChild(storage.Version, "GameContext").Value
  416. sort(init2, function(a, b)
  417.     return (a.initPriority or 0) > (b.initPriority or 0)
  418. end)
  419. for _, pl in ipairs(init2) do
  420.     pl:init()
  421. end
  422. init2 = nil
  423. Utilities.setupDestroyWatch()
  424. while not assetsLoaded or not Utilities.DefaultFont.loaded do
  425.     wait()
  426. end
  427. loaded = not TEST_LOADING_PERPETUALLY
  428. while not fadedOut do
  429.     wait()
  430. end
  431. _p.TeleportScreenUtil = {CreatingLoadingAssets = creatingLoadingAssets, AnimateLoading = animateLoading}
  432. local boostrap = _p.Bootstrap
  433. _p.Bootstrap = nil
  434. boostrap(rejoining, screen, bgFrame, assetsLoaded, forceContinue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement