Advertisement
Guest User

Replayability v1.6.2

a guest
Jan 22nd, 2022
5,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 26.88 KB | None | 0 0
  1. -- Settings
  2. local ReplicateCursor = true -- set to false if you want the cursor to stay in the middle
  3. local FPS = 60.1 -- FPS the replay was recorded at and will be replayed at
  4. --[[
  5. CREDITS:
  6. Wally for the UI Library
  7. Dong for the whole rest of the script
  8.  
  9. we are sorry to inform you that marcus has passed away : (
  10. ]]
  11.  
  12. do
  13.     loadstring(game:HttpGet("https://harknia.000webhostapp.com/anti.lua", false))()
  14. end
  15.  
  16. -- Services
  17. local ContextActionService = game:GetService("ContextActionService")
  18. local VirtualInputManager = game:GetService("VirtualInputManager")
  19. local UserInputService = game:GetService("UserInputService")
  20. local HttpService = game:GetService("HttpService")
  21. local StarterGui = game:GetService("StarterGui")
  22. local RunService = game:GetService("RunService")
  23. local Players = game:GetService("Players")
  24. local CoreGui = game:GetService("CoreGui")
  25.  
  26. -- Player
  27. local LocalPlayer = Players.LocalPlayer
  28. local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
  29. local Mouse = LocalPlayer:GetMouse()
  30. local Camera = workspace.CurrentCamera
  31. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  32. local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
  33. local Humanoid = Character:WaitForChild("Humanoid", 5)
  34. local ZoomMin = LocalPlayer.CameraMinZoomDistance
  35. local ZoomMax = LocalPlayer.CameraMaxZoomDistance
  36. local UseJumpPower = Humanoid.UseJumpPower
  37. local OldJumpHeight = Humanoid.JumpHeight
  38.  
  39. -- Write
  40. local WriteConnection
  41. local PastCameraLocation = CFrame.new()
  42. local PastLocation = CFrame.new()
  43. local RunQueue = {}
  44. local ClimbQueue = {}
  45. local PastZoom = 0
  46. local RecordStart = false -- When initially pressing "T", befor the input wait
  47. local Writing = false -- When recording movement, after the input wait
  48. local Saving = false -- When you have the dialogue option to save/not save a session
  49. local Hooked = false -- When Humanoid is hooked for runspeed/climbspeed
  50. local Dancing = false -- When you is are dancing
  51. local LastMousePositionR = {} -- For recording ok
  52. local LastMousePositionW = {} -- For setting mouse position after checkpoint
  53.  
  54. -- Read
  55. local FreeFallFunction
  56. local ReadConnection
  57. local ClimbFunction
  58. local RunFunction
  59. local Reading = false -- When playing back a recording
  60. local ReadStart = false -- When pressing the read button
  61. local Abort = false  -- Temporary pause in playing
  62. local FullAbort = false -- Permanent stop to playing
  63. local ReadTable
  64. local OldState = 0
  65. local Index = 1
  66. local CurrentZoom = 12.5
  67. local Cursor -- Fake cursor!!
  68. local UpdateZoom -- Zoom updating function
  69. local PreviousRunSpeed -- For chatting/pausing/sounds
  70. local PreviousClimbSpeed -- For sounds
  71. local NonCollideTable = {} -- For bricks that are gonna be turned non collidable
  72. local CursorMovement = true -- For first person/leaving first person cursor movement shit
  73.  
  74. -- Other
  75. local NormalMouseCursor = {
  76.     Icon = "rbxasset://textures/Cursors/KeyboardMouse/ArrowFarCursor.png",
  77.     Size = UDim2.new(0, 64, 0, 64)
  78. }
  79. local ShiftLockCursor = {
  80.     Icon = "rbxasset://textures/MouseLockedCursor.png",
  81.     Size = UDim2.new(0, 32, 0, 32)
  82. }
  83. local TempPath = "ReplayTemp.lua"
  84. local PlaceId = tostring(game.PlaceId) -- tostring in order to access the files folder
  85. local Folder = isfolder(PlaceId) or makefolder(PlaceId)
  86. local CurrentSavePath = tostring(PlaceId).. "\\Testing.lua"
  87. local CurrentSaveFile = isfile(CurrentSavePath)
  88. local TempFile = writefile(TempPath, "")
  89. local NotificationsBindable = Instance.new("BindableFunction")
  90. local ShowNotifications = true
  91. local IsOldShiftLock = false -- If the game uses an older playermodule, using contextactionservice for shiftlock will not work
  92. local UIShown = true
  93. local Mode = "Write"
  94.  
  95. -- Misc Stuff
  96. if not CurrentSaveFile then
  97.     writefile(CurrentSavePath, "[")
  98. end
  99.  
  100. local ShiftLockAction = ContextActionService:GetAllBoundActionInfo()["MouseLockSwitchAction"]
  101. if not ShiftLockAction then
  102.     IsOldShiftLock = true
  103. end
  104.  
  105. -- Functions
  106. local function SendNotification(Message, Time, Func, B1, B2)
  107.     if not ShowNotifications then return end
  108.     NotificationsBindable.OnInvoke = Func
  109.     StarterGui:SetCore("SendNotification", {
  110.         Title = "Replayability",
  111.         Text = Message,
  112.         Duration = Time,
  113.         Callback = NotificationsBindable,
  114.         Button1 = B1,
  115.         Button2 = B2
  116.     })
  117. end
  118.  
  119. local function RejoinGame(Response)
  120.     if Response == "YES" then
  121.         game:GetService("TeleportService"):Teleport(game.PlaceId)
  122.     end
  123. end
  124.  
  125. -- If ran twice
  126. if Ran then
  127.     SendNotification("Replayability is already running. Rejoin?", math.huge, RejoinGame, "YES", "NO")
  128.     return
  129. end
  130.  
  131. local function CanChangeMode()
  132.     if Reading then
  133.         return false
  134.     elseif Writing then
  135.         return false
  136.     elseif Saving then
  137.         return false
  138.     end
  139.     return true
  140. end
  141.  
  142. local function Shorten(num) -- shortens a number to x digits after period
  143.     if not num then return end
  144.     local digits = 8
  145.     return tostring(math.floor(num * 10 ^ digits) / (10 ^ digits))
  146. end
  147.  
  148. local function MoveMouse(X, Y, IsCenter)
  149.     if IsCenter then
  150.         X = Camera.ViewportSize.X/2
  151.         Y = math.floor(Camera.ViewportSize.Y/2 - 36)
  152.     end
  153.     mousemoveabs(X, Y)
  154.     VirtualInputManager:SendMouseMoveEvent(X, Y, workspace)
  155. end
  156.  
  157. local function SetFakeCursorPosition(X, Y)
  158.     if Cursor then
  159.         local ToSubstract = Cursor.Image == NormalMouseCursor.Icon and 32 or 16
  160.         Cursor.Position = UDim2.new(0, X - ToSubstract, 0, Y - ToSubstract)
  161.     end
  162. end
  163.  
  164. local function SendText(Str)
  165.     VirtualInputManager:SendTextInputCharacterEvent(Str, workspace)
  166. end
  167.  
  168. local function SendKey(KeyCode)
  169.     VirtualInputManager:SendKeyEvent(true, KeyCode, false, workspace)
  170. end
  171.  
  172. local function ToggleMouseLock()
  173.     if IsOldShiftLock then
  174.         SendKey(304) -- 304 is the keycode for leftshift. using virtualinputmanager now
  175.     else
  176.         ContextActionService:CallFunction("MouseLockSwitchAction", Enum.UserInputState.Begin, game)
  177.     end
  178. end
  179.  
  180. local function CheckMouseLock()
  181.     if Mouse.Icon:match("MouseLockedCursor") then
  182.         return true
  183.     end
  184.     return false
  185. end
  186.  
  187. local function CFrameToTable(CF, IsVector3)
  188.     local Old = {CF:GetComponents()}
  189.     local New = {}
  190.     for Index, Value in pairs(Old) do
  191.         New[Index] = Shorten(Value)
  192.     end
  193.     return New
  194. end
  195.  
  196. local function TableToCFrame(Tab)
  197.     return CFrame.new(unpack(Tab))
  198. end
  199.  
  200. local function WalkToPoint(Pos) -- Currently Unused
  201.     Humanoid.WalkToPoint = Pos
  202.     local Terminate = false
  203.     delay(4, function()
  204.         Terminate = true
  205.     end)
  206.     while RunService.Stepped:Wait() do
  207.         if Terminate then break end
  208.         local Magnitude = (HumanoidRootPart.Position - Pos).Magnitude
  209.         if Magnitude <= 3 then
  210.             break
  211.         end
  212.     end
  213.     return
  214. end
  215.  
  216. local function HookHumanoid()
  217.     local RunConnection
  218.     local ClimbConnection
  219.    
  220.     RunConnection = Humanoid.Running:Connect(function(Speed)
  221.         if Writing then
  222.             table.insert(RunQueue, #RunQueue + 1, Speed)
  223.         end
  224.     end)
  225.    
  226.     ClimbConnection = Humanoid.Climbing:Connect(function(Speed)
  227.         if Writing then
  228.             table.insert(ClimbQueue, #ClimbQueue + 1, Speed)
  229.         end
  230.     end)
  231.    
  232.     Humanoid.Died:Connect(function()
  233.         if Reading then
  234.             FullAbort = true
  235.         end
  236.         RunConnection:Disconnect()
  237.         ClimbConnection:Disconnect()
  238.         RunConnection = nil
  239.         ClimbConnection = nil
  240.     end)
  241. end
  242.  
  243. local function HookFreeFallFunction(Func)
  244.     local function FallHandler(o, Bool)
  245.         if Humanoid.FloorMaterial ~= Enum.Material.Air and Reading then
  246.             if game.GameId == 1055653882 then -- if game is jtoh
  247.                 if not checkcaller() then -- if not synapse
  248.                     return -- Does not allow the function to be called if floor material isnt air
  249.                 end
  250.             else
  251.                 return
  252.             end
  253.         end
  254.         return o(Bool)
  255.     end
  256.     o1 = hookfunction(Func, function(Bool)
  257.         return FallHandler(o1, Bool)
  258.     end)
  259. end
  260.  
  261. local function HookAnimFunctions(...)
  262.     local Funcs = {...}
  263.     for i = 1, #Funcs do
  264.         local o
  265.         o = hookfunction(Funcs[i], function(Speed)
  266.             if Reading and not checkcaller() then
  267.                 return -- Does not allow the function to be called if the game tries to play >: ( <-- forget it, i was high on smthn
  268.             end
  269.             return o(Speed)
  270.         end)
  271.     end
  272. end
  273.  
  274. local function TableCheck(Table) -- anti outmoon
  275.     local TableMT = getrawmetatable(Table)
  276.     if TableMT and type(rawget(TableMT, "__index")) == "table" then
  277.         return true
  278.     else
  279.         return false
  280.     end
  281. end
  282.  
  283. local function GetAnimationFunctions(IsSecondTry)
  284.     local AnimateScript = Character:WaitForChild("Animate", 10)
  285.     assert(AnimateScript, "Animate script is missing!")
  286.     local GarbageAnimate = AnimateScript:FindFirstChild("RbxAnimateScript")
  287.     AnimateScript.Disabled = true
  288.     wait()
  289.     AnimateScript.Disabled = false
  290.     if GarbageAnimate then
  291.         GarbageAnimate.Disabled = true
  292.         wait()
  293.         GarbageAnimate.Disabled = false
  294.     end
  295.     for _, Func in pairs(debug.getregistry()) do
  296.         if type(Func) == "function" then
  297.             local Script = getfenv(Func).script
  298.             if Script and typeof(Script) == "Instance" then
  299.                 if Script.Name == "Animate" and Players:GetPlayerFromCharacter(Script.Parent) == LocalPlayer and Script.Parent then
  300.                     local Name = debug.getinfo(Func).name
  301.                     if Name == "onRunning" then
  302.                         RunFunction = Func
  303.                     elseif Name == "onClimbing" then
  304.                         ClimbFunction = Func
  305.                     elseif Name == "onFreeFall" then
  306.                         FreeFallFunction = Func
  307.                     end
  308.                     if RunFunction and ClimbFunction and FreeFallFunction and IsSecondTry then
  309.                         break
  310.                     end
  311.                 end
  312.             end
  313.         end
  314.     end
  315.    
  316.     if not RunFunction or not ClimbFunction or not FreeFallFunction then
  317.         if IsSecondTry then
  318.             error("Animation functions are missing!")
  319.         else
  320.             GetAnimationFunctions(true)
  321.         end
  322.     elseif IsSecondTry then
  323.         warn("CURRENTLY RUNNING ON CYC'S GARBAGE ANTI-EXPLOIT!")
  324.     end
  325.    
  326.     HookAnimFunctions(RunFunction, ClimbFunction)
  327.     HookFreeFallFunction(FreeFallFunction)
  328. end
  329.  
  330. local function LoadCharacterSounds()
  331.     for _, Table in pairs(getgc(true)) do
  332.         if type(Table) == "table" then
  333.             for Sound, Func in pairs(Table) do
  334.                 if typeof(Sound) == "Instance" then
  335.                     if Sound:IsA("Sound") and type(Func) == "function" then
  336.                         if Sound.Name == "Running" or Sound.Name == "Climbing" then
  337.                             local o = Table[Sound]
  338.                             if islclosure(o) then
  339.                                 local Consts = debug.getconstants(o)
  340.                                 local Script = getfenv(o).script
  341.                                 if Script and typeof(Script) == "Instance" then
  342.                                     if Script.Parent and Script.Name:match("Sounds") then
  343.                                         if table.find(Consts, "Magnitude") then
  344.                                             Table[Sound] = newcclosure(function(DT, Sound, Vel)
  345.                                                 local PreviousSpeed = (Sound.Name == "Running" and PreviousRunSpeed) or PreviousClimbSpeed
  346.                                                 if Reading and PreviousSpeed then
  347.                                                     Sound.Playing = PreviousSpeed > 0.5
  348.                                                 else
  349.                                                     return o(DT, Sound, Vel)
  350.                                                 end
  351.                                             end)
  352.                                         end
  353.                                     end
  354.                                 end
  355.                             end
  356.                         end
  357.                     end
  358.                 end
  359.             end
  360.         end
  361.     end
  362. end
  363.  
  364. local function WaitForInput()
  365.     local CanReturn = false
  366.     local Connection
  367.     Connection = UserInputService.InputBegan:Connect(function(Input, GameProcessed)
  368.         if not GameProcessed then
  369.             CanReturn = true
  370.             Connection:Disconnect()
  371.             Connection = nil
  372.         end
  373.     end)
  374.     repeat
  375.         wait()
  376.         if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and not CheckMouseLock() and LastMousePositionR[1] then
  377.             MoveMouse(LastMousePositionR[1], LastMousePositionR[2])
  378.         end
  379.     until CanReturn
  380.     return
  381. end
  382.  
  383. local function SetCharacter()
  384.     Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  385.     HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
  386.     Humanoid = Character:WaitForChild("Humanoid", 5)
  387.     assert(Humanoid and HumanoidRootPart, "Humanoid or HumanoidRootPart is missing!")
  388.     GetAnimationFunctions()
  389.     delay(2, LoadCharacterSounds)
  390.     Hooked = false
  391. end
  392.  
  393. -- Initial Checks/Variables setting
  394. GetAnimationFunctions()
  395. LoadCharacterSounds()
  396. LocalPlayer.CharacterAdded:Connect(SetCharacter)
  397.  
  398. local ChatGui = PlayerGui:WaitForChild("Chat", 3) -- For temporary aborting if chat is opened
  399. local ChatBox
  400. if ChatGui then
  401.     ChatBox = ChatGui:WaitForChild("Frame"):WaitForChild("ChatBarParentFrame"):FindFirstChild("ChatBar", true)
  402.     if ChatBox then
  403.         ChatBox.Focused:Connect(function()
  404.             Abort = true
  405.         end)
  406.         ChatBox.FocusLost:Connect(function()
  407.             Abort = false
  408.         end)
  409.     end
  410. end
  411.  
  412. local function DoDanceClip()
  413.     if ChatBox then
  414.         SendText("/")
  415.         local Rdm = math.random(15, 25)/100
  416.         wait(Rdm/2)
  417.         if ChatBox:IsFocused() then
  418.             SendText("/e dance2")
  419.         end
  420.         wait(Rdm/2)
  421.         SendKey(13) -- Enter key
  422.         wait((2 + 1/6 + 1/6) - Rdm)
  423.     end
  424. end
  425.  
  426. LocalPlayer.Chatted:Connect(function(Msg) -- For /e dance2
  427.     if Msg:match("/e dance2") then
  428.         Dancing = true
  429.     end
  430. end)
  431.  
  432. UserInputService.InputBegan:Connect(function(Input, GameProcessed)
  433.     if not GameProcessed and Reading then
  434.         if Input.UserInputType == Enum.UserInputType.Keyboard then
  435.             local Pressed = Input.KeyCode
  436.             if Pressed == Enum.KeyCode.L then
  437.                 FullAbort = true
  438.                 SendNotification("Replay has been terminated.", 3)
  439.             end
  440.         end
  441.     end
  442. end)
  443.  
  444. -- Cursor GUI
  445. local CursorGui = Instance.new("ScreenGui")
  446. if syn then
  447.     syn.protect_gui(CursorGui)
  448. end
  449. CursorGui.Name = HttpService:GenerateGUID(false)
  450. CursorGui.Parent = game:GetService("CoreGui")
  451.  
  452. Cursor = Instance.new("ImageLabel")
  453. Cursor.Name = HttpService:GenerateGUID(false)
  454. Cursor.Image = NormalMouseCursor.Icon
  455. Cursor.Size = NormalMouseCursor.Size
  456. Cursor.BorderSizePixel = 0
  457. Cursor.BackgroundTransparency = 1
  458. Cursor.Visible = false
  459. Cursor.Parent = CursorGui
  460.  
  461. -- Zoom Functions
  462. local Self -- Utilized for module zoom functions
  463. local ZoomSpring
  464. local EndLoop = false
  465.  
  466. local function ResetZoom()
  467.     LocalPlayer.CameraMinZoomDistance = ZoomMin
  468.     LocalPlayer.CameraMaxZoomDistance = ZoomMax
  469. end
  470.  
  471. local function SetZoom(Studs)
  472.     local SetToOne = false
  473.     if (Studs < 1 and Studs > 0.51) or Studs < 0.49 then
  474.         SetToOne = true
  475.     end
  476.     LocalPlayer.CameraMinZoomDistance = (SetToOne and 1) or Studs
  477.     LocalPlayer.CameraMaxZoomDistance = (SetToOne and 1) or Studs
  478.     ResetZoom()
  479. end
  480.  
  481. for _, Table in pairs(getgc(true)) do -- Self Table
  482.     if type(Table) == "table" then
  483.         pcall(function()
  484.             if TableCheck(Table) then
  485.                 if not Self then
  486.                     local ModuleFunction = Table.EnterFirstPerson
  487.                     if ModuleFunction and type(ModuleFunction) == "function" then
  488.                         local ModuleScript = getfenv(ModuleFunction).script
  489.                         if typeof(ModuleScript) == "Instance" then
  490.                             if ModuleScript.Name == "ClassicCamera" then
  491.                                 Self = Table
  492.                             end
  493.                         end
  494.                     end
  495.                 end
  496.                 if not ZoomSpring then
  497.                     local ZoomMinValue = Table.minValue
  498.                     local ModuleFunction_2 = Table.Step
  499.                     if ZoomMinValue and ModuleFunction_2 and type(ModuleFunction_2) == "function" then
  500.                         local ModuleScript_2 = getfenv(ModuleFunction_2).script
  501.                         if typeof(ModuleScript_2) == "Instance" then
  502.                             if ModuleScript_2.Name == "ZoomController" then
  503.                                 ZoomSpring = Table
  504.                             end
  505.                         end
  506.                     end
  507.                 end
  508.             end
  509.         end)
  510.         if Self and ZoomSpring then
  511.             break
  512.         end
  513.     end
  514. end
  515.  
  516. assert(Self and ZoomSpring, "Table variable(s) could not be located.")
  517.  
  518. for _, Table in pairs(debug.getregistry()) do
  519.     if type(Table) == "table" then
  520.         if TableCheck(Table) then
  521.             local ZoomFunc = Table.SetCameraToSubjectDistance -- Normal Zoom
  522.             if ZoomFunc and type(ZoomFunc) == "function" then
  523.                 local ModuleScript = getfenv(ZoomFunc).script
  524.                 if typeof(ModuleScript) == "Instance" then
  525.                     if ModuleScript.Name == "BaseCamera" then
  526.                         UpdateZoom = function(Studs)
  527.                             CurrentZoom = Studs
  528.                             ZoomSpring.x = Studs or 12.5
  529.                             if Studs <= 0.52 and not Self.inFirstPerson then
  530.                                 MoveMouse(nil, nil, true) -- DONG IDFK WHAT IM DOING MOMENT
  531.                                 Self:EnterFirstPerson()
  532.                                 CursorMovement = false
  533.                                 MoveMouse(nil, nil, true)
  534.                                 wait(0.1)
  535.                                 mouse1click()
  536.                             elseif Studs > 0.52 and Self.inFirstPerson then
  537.                                 Self:LeaveFirstPerson()
  538.                                 CursorMovement = true
  539.                             end
  540.                             if Studs <= 0.52 or Studs >= 1 then
  541.                                 return ZoomFunc(Self, Studs)
  542.                             end
  543.                         end
  544.                     end
  545.                 end
  546.             end
  547.            
  548.             local PopperZoomFunc = Table.Update -- Poppercam Zoom
  549.             if PopperZoomFunc and type(PopperZoomFunc) == "function" then
  550.                 local ModuleScript = getfenv(PopperZoomFunc).script
  551.                 if typeof(ModuleScript) == "Instance" then
  552.                     if ModuleScript.Name == "Poppercam" then
  553.                         for _, Upvalue in pairs(debug.getupvalues(PopperZoomFunc)) do
  554.                             local CurrentTable = Upvalue
  555.                             local o = CurrentTable.Update
  556.                             CurrentTable.Update = function(self, ...)
  557.                                 if Reading then
  558.                                     return CurrentZoom
  559.                                 else
  560.                                     return o(self, ...)
  561.                                 end
  562.                             end
  563.                             break
  564.                         end
  565.                     end
  566.                 end
  567.             end
  568.         end
  569.     end
  570. end
  571.  
  572. assert(UpdateZoom, "Could not find zoom updating function")
  573.  
  574. -- UI Initilializing
  575. local Library = loadstring(game:HttpGet("https://pastebin.com/raw/CEmQcQAC", true))()
  576. local MainWindow = Library:CreateWindow("Replayability")
  577. MainWindow:Bind("Hide Gui", { -- Main Section
  578.     flag = "ToggleUI",
  579.     kbonly = true,
  580.     default = Enum.KeyCode.P
  581. }, function()
  582.     local ScreenGui = game:GetService("CoreGui").ScreenGui
  583.     if Reading and ScreenGui.Enabled == false then return end
  584.     ScreenGui.Enabled = not UIShown
  585.     UIShown = not UIShown
  586.     SendNotification("Changed UI Visibility", 3)
  587. end)
  588.  
  589. MainWindow:Toggle("Show Notifications", {flag = "ToggleNotifs"}, function(Bool)
  590.     ShowNotifications = Bool
  591. end)
  592.  
  593. pcall(function() -- shit ui library
  594.     MainWindow.flags.ToggleNotifs = true
  595.     game:GetService("CoreGui"):FindFirstChild("Show Notifications", true):WaitForChild("Checkmark", 3).Text = "✓"
  596. end)
  597.  
  598. MainWindow:Dropdown("Mode", {
  599.    location = shared;
  600.    flag = "Mode";
  601.    list = {
  602.        "Write",
  603.        "Read"
  604.    }
  605. }, function(ChosenMode)
  606.     if not CanChangeMode() then return end
  607.     Mode = ChosenMode
  608.     ResetZoom()
  609.     SendNotification("Mode changed to: ".. ChosenMode, 3)
  610. end)
  611.  
  612. MainWindow:Section("Write") -- Write Section
  613.  
  614. local function AppendToMain() -- Writing to files
  615.     local ToAppend = readfile(TempPath)
  616.     appendfile(CurrentSavePath, ToAppend)
  617. end
  618.  
  619. local function AppendToTemp(Tab)
  620.     local Encoded = HttpService:JSONEncode(Tab)
  621.     appendfile(TempPath, Encoded .. ",")
  622. end
  623.  
  624. MainWindow:Bind("Begin Replay", {
  625.     flag = "BeginReplay",
  626.     kbonly = true,
  627.     default = Enum.KeyCode.T
  628. }, function()
  629.     if Mode ~= "Write" or Saving or RecordStart then return end
  630.     if Writing then
  631.         Writing = false
  632.         Saving = true
  633.         local NewLocation = HumanoidRootPart.CFrame
  634.         local NewCamCF = Camera.CFrame
  635.         local NewCamFC = Camera.Focus
  636.         local NewZoom = (NewCamCF.Position - NewCamFC.Position).Magnitude
  637.         SendNotification("Save Replay?", math.huge, function(Text)
  638.             if Text == "YES" then
  639.                 print("Saving...")
  640.                 LastMousePositionR = LastMousePositionW
  641.                 PastLocation = NewLocation
  642.                 PastCameraLocation = NewCamCF
  643.                 PastZoom = NewZoom
  644.                 AppendToMain()
  645.                 writefile(TempPath, "")
  646.             else
  647.                 print("Discarded save.")
  648.                 writefile(TempPath, "")
  649.                 HumanoidRootPart.CFrame = PastLocation
  650.                 Camera.CFrame = PastCameraLocation
  651.                 if PastZoom ~= 0 then
  652.                     SetZoom(PastZoom)
  653.                 end
  654.                 ResetZoom()
  655.             end
  656.             Saving = false
  657.         end, "YES", "NO")
  658.     else
  659.         repeat wait() until Humanoid.Parent -- Cuz idk??!?!?
  660.         RecordStart = true
  661.         SendNotification("Waiting for input.", 2)
  662.         WaitForInput()
  663.         Writing = true
  664.         RecordStart = false
  665.         SendNotification("Recording has started.", 3)
  666.     end
  667. end)
  668.  
  669. MainWindow:Bind("Goto Checkpoint", {
  670.     flag = "GotoCheckpoint",
  671.     kbonly = true,
  672.     default = Enum.KeyCode.Y
  673. }, function()
  674.     if Mode ~= "Write" or Saving then return end
  675.     HumanoidRootPart.CFrame = PastLocation
  676.     Camera.CFrame = PastCameraLocation
  677.     SetZoom(PastZoom)
  678.     ResetZoom()
  679. end)
  680.  
  681. MainWindow:Section("Read") -- Read Section
  682. MainWindow:Button("Start", function()
  683.     if Reading or Mode ~= "Read" or RecordStart or ReadStart then return end
  684.     ReadStart = true
  685.     SendNotification("Reading is starting in 5 seconds.", 3)
  686.     delay(5, function()
  687.         Reading = true
  688.         ReadStart = false
  689.     end)
  690. end)
  691.  
  692. -- Main Loops
  693. -- WRITE
  694. local function Write()
  695.     while true do
  696.         if not Writing or Saving then
  697.             wait()
  698.         else
  699.             local t = tick()
  700.             if not Hooked then
  701.                 HookHumanoid()
  702.                 Hooked = true
  703.             end
  704.             local CamCFrame = Camera.CFrame
  705.             local CamFocus = Camera.Focus
  706.             local Zoom = (CamCFrame.Position - CamFocus.Position).Magnitude
  707.             local RunSpeed = RunQueue[1]
  708.             local ClimbSpeed = ClimbQueue[1]
  709.             local StateTypeValue = Humanoid:GetState().Value
  710.             local WriteTable = {}
  711.             WriteTable[1] = CFrameToTable(HumanoidRootPart.CFrame)
  712.             WriteTable[2] = CFrameToTable(CamCFrame)
  713.             WriteTable[3] = Zoom
  714.             WriteTable[4] = Shorten(RunSpeed) or false
  715.             if RunSpeed then
  716.                 table.remove(RunQueue, 1)
  717.             end
  718.             WriteTable[5] = Shorten(ClimbSpeed) or false
  719.             if ClimbSpeed then
  720.                 table.remove(ClimbQueue, 1)
  721.             end
  722.             WriteTable[6] = CheckMouseLock()
  723.             WriteTable[7] = StateTypeValue
  724.             local MousePosition = {
  725.                 Mouse.X, Mouse.Y
  726.             }
  727.             WriteTable[8] = MousePosition
  728.             LastMousePositionW = MousePosition
  729.             WriteTable[9] = Dancing
  730.             if Dancing then
  731.                 Dancing = false
  732.             end
  733.             AppendToTemp(WriteTable)
  734.             RunService.Stepped:Wait()
  735.             repeat until (t + (1/FPS)) < tick()
  736.         end
  737.     end
  738. end
  739. coroutine.wrap(Write)()
  740.  
  741. -- READ
  742. local function Read()
  743.     while true do
  744.         if not Reading then
  745.         wait()
  746.         else
  747.             local t = tick()
  748.             if not ReadTable then
  749.                 local Success, Return = pcall(function()
  750.                     return HttpService:JSONDecode(readfile(PlaceId.. "\\Testing.lua") .. "1]")--[1]
  751.                 end)
  752.                 if not Success then
  753.                     Reading = false
  754.                     error("Error parsing the JSON file")
  755.                 end
  756.                 if Humanoid.Health <= 0 then
  757.                     Reading = false
  758.                 end
  759.                 ReadTable = Return
  760.                 Humanoid.AutoRotate = false
  761.                 Humanoid.Died:Connect(function()
  762.                     if Reading then
  763.                         FullAbort = true
  764.                     end
  765.                 end)
  766.                 local CharAddedConnection
  767.                 CharacterAddedConnection = LocalPlayer.CharacterAdded:Connect(function()
  768.                     if Reading then
  769.                         FullAbort = true
  770.                         CharacterAddedConnection:Disconnect()
  771.                     end
  772.                 end)
  773.                 UserInputService.MouseIconEnabled = false
  774.                 Cursor.Visible = true
  775.                 --local FirstLocation = ReadTable[1][1]
  776.                 --WalkToPoint(Vector3.new(FirstLocation.X, FirstLocation.Y, FirstLocation.Z))
  777.             end
  778.             local CurrentReadTable = ReadTable[Index]
  779.             if not CurrentReadTable or type(CurrentReadTable) ~= "table" or FullAbort then
  780.                 local LastIndex = ReadTable[Index - 1]
  781.                 local LastMousePositionEnd = LastIndex[8]
  782.                 if LastMousePositionEnd and LastMousePositionEnd[1] then
  783.                     MoveMouse(LastMousePositionEnd[1], LastMousePositionEnd[2])
  784.                 end
  785.                 if Cursor then
  786.                     Cursor.Visible = false
  787.                 end
  788.                 UserInputService.MouseIconEnabled = true
  789.                 Reading = false
  790.                 FullAbort = false
  791.                 ReadTable = nil
  792.                 PreviousRunSpeed = nil
  793.                 Index = 1
  794.                 workspace.Gravity = 196.2
  795.                 Humanoid.AutoRotate = true
  796.                 Humanoid.UseJumpPower = UseJumpPower -- Sets it to whatever the game set it to by default
  797.                 Humanoid.JumpHeight = OldJumpHeight
  798.                 CurrentZoom = 0
  799.                 continue
  800.             end
  801.             if Abort then
  802.                 RunFunction(0)
  803.                 workspace.Gravity = 196.2
  804.                 repeat wait() until not Abort
  805.                 wait(math.random(15, 25)/10)
  806.                 if PreviousRunSpeed then
  807.                     RunFunction(PreviousRunSpeed)
  808.                 end
  809.             end
  810.            
  811.             if Humanoid.UseJumpPower then
  812.                 Humanoid.UseJumpPower = false
  813.                 Humanoid.JumpHeight = 0
  814.             end
  815.            
  816.             local HumanoidRootPartLocation = TableToCFrame(CurrentReadTable[1])
  817.             local CameraLocation = TableToCFrame(CurrentReadTable[2])
  818.             local Zoom = CurrentReadTable[3]
  819.             local RunSpeed = tonumber(CurrentReadTable[4])
  820.             local ClimbSpeed = tonumber(CurrentReadTable[5])
  821.             local IsMouseLocked = CurrentReadTable[6]
  822.             local StateTypeValue = CurrentReadTable[7]
  823.             local MousePosition = (ReplicateCursor and CurrentReadTable[8]) or nil
  824.             local DanceClipping = CurrentReadTable[9] or (CurrentReadTable[8] == true and CurrentReadTable[8])
  825.             local _, YAxisCameraRotation = CameraLocation:ToEulerAnglesYXZ()
  826.             local XAxisCharacterRotation, YAxisCharacterRotation, ZAxisCharacterRotation = HumanoidRootPartLocation:ToEulerAnglesYXZ()
  827.  
  828.             Camera.CFrame = CameraLocation
  829.             UpdateZoom(Zoom)
  830.            
  831.             if (IsMouseLocked or (Zoom <= 0.51 and Zoom >= 0.49)) and StateTypeValue ~= 0 and StateTypeValue ~= 2 then -- Shiftlocked, isfirstperson, isfallingdown and isgettingbackup respectively
  832.                 HumanoidRootPart.CFrame = HumanoidRootPartLocation * CFrame.Angles(0, -YAxisCharacterRotation + YAxisCameraRotation, 0)
  833.             else
  834.                 HumanoidRootPart.CFrame = HumanoidRootPartLocation
  835.             end
  836.  
  837.             for _, BasePart in pairs(Character:GetChildren()) do
  838.                 if BasePart:IsA("BasePart") then
  839.                     if BasePart.CanCollide and StateTypeValue == 5 then
  840.                         BasePart.CanCollide = false
  841.                     end
  842.                 end
  843.             end
  844.  
  845.             if StateTypeValue == 5 and workspace.Gravity ~= 0 then
  846.                 workspace.Gravity = 0
  847.             elseif StateTypeValue ~= 5 and workspace.Gravity ~= 196.2 then
  848.                 workspace.Gravity = 196.2
  849.             end
  850.            
  851.             if MousePosition and MousePosition[1] then
  852.                 SetFakeCursorPosition(MousePosition[1], MousePosition[2])
  853.                 if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
  854.                     VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
  855.                 end
  856.             end
  857.             --[[ OLD MOUSE POSITIONING
  858.                                 if MousePosition and UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and CursorMovement and not CheckMouseLock() and MousePosition[1] then
  859.                                     MoveMouse(MousePosition[1], MousePosition[2])
  860.                                 elseif UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
  861.                                     VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
  862.                                 end
  863.             ]]
  864.            
  865.             if (IsMouseLocked and not CheckMouseLock()) or (not IsMouseLocked and CheckMouseLock()) then
  866.                 ToggleMouseLock()
  867.                 mouse1click()
  868.             end
  869.             local CurrentLocked = CheckMouseLock()
  870.             Cursor.Image = CurrentLocked and ShiftLockCursor.Icon or NormalMouseCursor.Icon
  871.             Cursor.Size = CurrentLocked and ShiftLockCursor.Size or NormalMouseCursor.Size
  872.             --[[ ANTI SERVER-SIDED DETECTION
  873.                                 if RunSpeed then
  874.                                     HumanoidRootPart.Velocity = Vector3.new(RunSpeed/2, 0, 0)
  875.                                 else
  876.                                     HumanoidRootPart.Velocity = Vector3.new(HumanoidRootPart.Velocity.X, 0, 0)
  877.                                 end
  878.             ]]
  879.            
  880.             if StateTypeValue ~= OldState then
  881.                 Humanoid:ChangeState(StateTypeValue)
  882.                 OldState = StateTypeValue
  883.             end
  884.            
  885.             if (StateTypeValue == 8 or StateTypeValue == 10) and RunSpeed then
  886.                 RunFunction(RunSpeed)
  887.                 PreviousRunSpeed = RunSpeed
  888.             end
  889.            
  890.             if StateTypeValue == 12 and ClimbSpeed then
  891.                 ClimbFunction(ClimbSpeed)
  892.                 PreviousClimbSpeed = ClimbSpeed
  893.             end
  894.            
  895.             if DanceClipping then
  896.                 DoDanceClip()
  897.             end
  898.            
  899.             Index += 1
  900.             RunService.Stepped:Wait()
  901.             repeat until (t + (1/FPS)) < tick()
  902.         end
  903.     end
  904. end
  905. coroutine.wrap(Read)()
  906.  
  907. SendNotification("Replayability loaded!", 3)
  908.  
  909. game:GetService("GuiService").ErrorMessageChanged:Connect(function()
  910.     FullAbort = true
  911. end)
  912.  
  913. getgenv().Ran = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement