mastersmzzz

Replay

Feb 27th, 2023
3,730
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.42 KB | None | 0 0
  1. -- Settings
  2. local ReplicateCursor = false -- set it to false if you want cursor in the middle
  3. local FPS = 75.1 -- the fps that replay will play on
  4.  
  5. --[[
  6. REPLAYABILITY VERSION 1.7.3
  7. (unofficial)
  8.  
  9. UPDATE INFO:
  10. - Added Count Frames
  11. - Added Start at frame
  12. - Dying and respawning during a replay is now supported
  13. - Uses the game's default gravity instead of 196.2 always
  14.  
  15.  
  16. CREDITS:
  17. Wally for the UI Library
  18. Dong for the original script
  19. Plusgiant5 for updating the script
  20.  
  21. HOW TO USE IT?:
  22. https://www.youtube.com/watch?v=UvaeUzKmqMc&t=70s
  23. ]]
  24.  
  25. loadstring(game:HttpGet("https://raw.githubusercontent.com/plusgiant5/Libraries/main/loadstrings/anti.lua", false))()
  26.  
  27. -- Services
  28. local ContextActionService = game:GetService("ContextActionService")
  29. local VirtualInputManager = game:GetService("VirtualInputManager")
  30. local UserInputService = game:GetService("UserInputService")
  31. local HttpService = game:GetService("HttpService")
  32. local StarterGui = game:GetService("StarterGui")
  33. local RunService = game:GetService("RunService")
  34. local Players = game:GetService("Players")
  35. local CoreGui = game:GetService("CoreGui")
  36.  
  37. -- Player
  38. local LocalPlayer = Players.LocalPlayer
  39. local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
  40. local PlayerScripts = LocalPlayer:WaitForChild("PlayerScripts")
  41. local Mouse = LocalPlayer:GetMouse()
  42. local Camera = workspace.CurrentCamera
  43. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  44. local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart", 5)
  45. local Humanoid = Character:WaitForChild("Humanoid", 5)
  46. local ZoomMin = LocalPlayer.CameraMinZoomDistance
  47. local ZoomMax = LocalPlayer.CameraMaxZoomDistance
  48. local UseJumpPower = Humanoid.UseJumpPower
  49. local OldJumpHeight = Humanoid.JumpHeight
  50. local NewAnimate = game:GetObjects("rbxassetid://9326088902")[1]
  51.  
  52. -- Write
  53. local WriteConnection
  54. local PastCameraLocation = CFrame.new()
  55. local PastLocation = CFrame.new()
  56. local RunQueue = {}
  57. local ClimbQueue = {}
  58. local PastZoom = 0
  59. local RecordStart = false -- When initially pressing "T", befor the input wait
  60. local Writing = false -- When recording movement, after the input wait
  61. local Saving = false -- When you have the dialogue option to save/not save a session
  62. local Hooked = false -- When Humanoid is hooked for runspeed/climbspeed
  63. local Dancing = false -- When you is are dancing
  64. local LastMousePositionR = {} -- For setting mouse position after checkpoint
  65. local LastMousePositionW = {} -- For recording ok
  66. local SentDeadSignal = false -- So there is never 2 dead frames next to eachother
  67.  
  68. -- Read
  69. local RunFunction
  70. local ClimbFunction
  71. local ReadConnection
  72. local Reading = false -- When playing back a recording
  73. local ReadStart = false -- When pressing the read button
  74. local Abort = false -- Temporary pause in playing
  75. local FullAbort = false -- Permanent stop to playing
  76. local ReadTable
  77. local OldState = 0
  78. local Index = 1
  79. local CurrentZoom = 12.5
  80. local Cursor -- Fake cursor!!
  81. local UpdateZoom -- Zoom updating function
  82. local PreviousRunSpeed -- For chatting/pausing/sounds
  83. local PreviousClimbSpeed -- For sounds
  84. local NonCollideTable = {} -- For bricks that are gonna be turned non collidable
  85. local CursorMovement = true -- For first person/leaving first person cursor movement shit
  86. local StartFrame = 1 -- Frame to start reading at, changed by the Start at frame: box
  87.  
  88. -- Other
  89. local NormalMouseCursor = {
  90. Icon = "rbxasset://textures/Cursors/KeyboardMouse/ArrowFarCursor.png",
  91. Size = UDim2.new(0, 64, 0, 64)
  92. }
  93. local ShiftLockCursor = {
  94. Icon = "rbxasset://textures/MouseLockedCursor.png",
  95. Size = UDim2.new(0, 32, 0, 32)
  96. }
  97. local TempPath = ""
  98. local PlaceId = tostring(game.PlaceId) -- tostring in order to access the files folder
  99. local Folder = isfolder(PlaceId) or makefolder(PlaceId)
  100. local CurrentSavePath = tostring(PlaceId).. "\\Testing.lua"
  101. local CurrentSaveFile = isfile(CurrentSavePath)
  102. local NotificationsBindable = Instance.new("BindableFunction")
  103. local ShowNotifications = true
  104. local IsOldShiftLock = false -- If the game uses an older playermodule, using contextactionservice for shiftlock will not work
  105. local CycAnti = false
  106. local UIShown = true
  107. local Mode = "Write"
  108. local DefaultGravity = workspace.Gravity -- Usually DefaultGravity but some games change it
  109.  
  110. -- Misc Stuff
  111. if not CurrentSaveFile then
  112. writefile(CurrentSavePath, "[")
  113. end
  114.  
  115. local ShiftLockAction = ContextActionService:GetAllBoundActionInfo()["MouseLockSwitchAction"]
  116. if not ShiftLockAction then
  117. IsOldShiftLock = true
  118. end
  119.  
  120. if not mouse1click then
  121. mouse1click = function() end
  122. mousemoveabs = function() end
  123. end
  124.  
  125. _G.GlobalReading = function()
  126. return Reading
  127. end
  128.  
  129. -- Functions
  130. local function SendNotification(Message, Time, Func, B1, B2)
  131. if not ShowNotifications then return end
  132. NotificationsBindable.OnInvoke = Func
  133. StarterGui:SetCore("SendNotification", {
  134. Title = "Replayability",
  135. Text = Message,
  136. Duration = Time,
  137. Callback = NotificationsBindable,
  138. Button1 = B1,
  139. Button2 = B2
  140. })
  141. end
  142.  
  143. local function RejoinGame(Response)
  144. if Response == "YES" then
  145. game:GetService("TeleportService"):Teleport(game.PlaceId)
  146. end
  147. end
  148.  
  149. -- If ran twice
  150. if Ran then
  151. SendNotification("Replayability is already running. Rejoin?", math.huge, RejoinGame, "YES", "NO")
  152. return
  153. end
  154.  
  155. local function CanChangeMode()
  156. if Reading then
  157. return false
  158. elseif Writing then
  159. return false
  160. elseif Saving then
  161. return false
  162. end
  163. return true
  164. end
  165.  
  166. local function Shorten(num) -- shortens a number to x digits after period
  167. if not num then return end
  168. local digits = 8
  169. return tostring(math.floor(num * 10 ^ digits) / (10 ^ digits))
  170. end
  171.  
  172. local function MoveMouse(X, Y, IsCenter)
  173. if not ReplicateCursor then return end
  174. if IsCenter then
  175. X = Camera.ViewportSize.X/2
  176. Y = math.floor(Camera.ViewportSize.Y/2 - 36)
  177. end
  178. mousemoveabs(X, Y)
  179. VirtualInputManager:SendMouseMoveEvent(X, Y, workspace)
  180. end
  181.  
  182. local function SetFakeCursorPosition(X, Y)
  183. if Cursor then
  184. local ToSubstract = Cursor.Image == NormalMouseCursor.Icon and 32 or 16
  185. Cursor.Position = UDim2.new(0, X - ToSubstract, 0, Y - ToSubstract)
  186. end
  187. end
  188.  
  189. local function SendText(Str)
  190. VirtualInputManager:SendTextInputCharacterEvent(Str, workspace)
  191. end
  192.  
  193. local function SendKey(KeyCode)
  194. VirtualInputManager:SendKeyEvent(true, KeyCode, false, workspace)
  195. end
  196.  
  197. local function ToggleMouseLock()
  198. if IsOldShiftLock then
  199. SendKey(304) -- 304 is the keycode for leftshift. using virtualinputmanager now
  200. else
  201. ContextActionService:CallFunction("MouseLockSwitchAction", Enum.UserInputState.Begin, game)
  202. end
  203. end
  204.  
  205. local function CheckMouseLock()
  206. if Mouse.Icon:match("MouseLockedCursor") then
  207. return true
  208. end
  209. return false
  210. end
  211.  
  212. local function CFrameToTable(CF, IsVector3)
  213. local Old = {CF:GetComponents()}
  214. local New = {}
  215. for Index, Value in pairs(Old) do
  216. New[Index] = Shorten(Value)
  217. end
  218. return New
  219. end
  220.  
  221. local function TableToCFrame(Tab)
  222. return CFrame.new(unpack(Tab))
  223. end
  224.  
  225. local function WalkToPoint(Pos) -- Currently Unused
  226. Humanoid.WalkToPoint = Pos
  227. local Terminate = false
  228. delay(4, function()
  229. Terminate = true
  230. end)
  231. while RunService.Stepped:Wait() do
  232. if Terminate then break end
  233. local Magnitude = (HumanoidRootPart.Position - Pos).Magnitude
  234. if Magnitude <= 3 then
  235. break
  236. end
  237. end
  238. return
  239. end
  240.  
  241. local function HookHumanoid()
  242. local RunConnection
  243. local ClimbConnection
  244.  
  245. RunConnection = Humanoid.Running:Connect(function(Speed)
  246. if Writing then
  247. table.insert(RunQueue, #RunQueue + 1, Speed)
  248. end
  249. end)
  250.  
  251. ClimbConnection = Humanoid.Climbing:Connect(function(Speed)
  252. if Writing then
  253. table.insert(ClimbQueue, #ClimbQueue + 1, Speed)
  254. end
  255. end)
  256.  
  257. Humanoid.Died:Connect(function()
  258. if Reading then
  259. --FullAbort = true
  260. end
  261. RunConnection:Disconnect()
  262. ClimbConnection:Disconnect()
  263. RunConnection = nil
  264. ClimbConnection = nil
  265. end)
  266. end
  267.  
  268. local function HookFreeFallFunction(Func) -- NOT USED ANYMORE!! MUAHAHAHAHAHAH!! I HAVE SEVERE MENTAL ILLNESS!!
  269. local function FallHandler(o, Bool)
  270. if Humanoid.FloorMaterial ~= Enum.Material.Air and Reading then
  271. if game.GameId == 1055653882 then -- if game is jtoh
  272. if not checkcaller() then -- if not synapse
  273. return -- Does not allow the function to be called if floor material isnt air
  274. end
  275. else
  276. return
  277. end
  278. end
  279. return o(Bool)
  280. end
  281. o1 = hookfunction(Func, function(Bool)
  282. return FallHandler(o1, Bool)
  283. end)
  284. end
  285.  
  286. local function HookAnimFunction(Func)
  287. local o
  288. o = hookfunction(Func, function(Speed)
  289. if Reading and not checkcaller() then
  290. return -- Does not allow the function to be called if the game tries to play >: ( <-- forget it, i was high on smthn
  291. end
  292. return o(Speed)
  293. end)
  294. end
  295.  
  296. local function TableCheck(Table) -- anti outmoon
  297. local TableMT = getrawmetatable(Table)
  298. if TableMT and type(rawget(TableMT, "__index")) == "table" then
  299. return true
  300. else
  301. return false
  302. end
  303. end
  304.  
  305. local function GetAnimationFunctions(IsSecondTry)
  306. local oldanimate = Character:WaitForChild("Animate", 1)
  307. if oldanimate then
  308. oldanimate:Destroy()
  309. end
  310. local n = NewAnimate:Clone()
  311. n.Disabled = true
  312. n.Parent = game.Players.LocalPlayer.Character
  313. getfenv().script = n
  314. local r,e = loadstring(n.Source)
  315. if not r then
  316. error("ERROR IN NEWANIMATE: "..e)
  317. else
  318. r()
  319. end
  320. repeat
  321. wait()
  322. --print("Waiting:",_G.RunFunction,_G.ClimbFunction)
  323. until _G.RunFunction and _G.ClimbFunction
  324. RunFunction = _G.RunFunction
  325. ClimbFunction = _G.ClimbFunction
  326. _G.RunFunction = nil
  327. _G.ClimbFunction = nil
  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. task.delay(1, LoadCharacterSounds)
  390. Hooked = false
  391. end
  392.  
  393. -- Initial Checks/Variables setting
  394. if LocalPlayer.Character:FindFirstChild("Animate") then
  395. LocalPlayer.Character.Animate:Destroy()
  396. for _,v in pairs(game.Players.LocalPlayer.Character.Humanoid:GetPlayingAnimationTracks()) do
  397. v:Stop()
  398. end
  399. end
  400. wait(.5)
  401. GetAnimationFunctions()
  402. task.delay(1, LoadCharacterSounds)
  403. LocalPlayer.CharacterAdded:Connect(SetCharacter)
  404.  
  405. local ChatGui = PlayerGui:WaitForChild("Chat", 3) -- Replay will be paused/aborted if chat is typing, you can change how long you for it
  406. local ChatBox
  407. if ChatGui then
  408. ChatBox = ChatGui:WaitForChild("Frame"):WaitForChild("ChatBarParentFrame"):FindFirstChild("ChatBar", true)
  409. if ChatBox then
  410. ChatBox.Focused:Connect(function()
  411. if Cursor.Image ~= ShiftLockCursor.Icon and Reading then
  412. Cursor.Image = "rbxasset://textures/Cursors/KeyboardMouse/ArrowCursor.png"
  413. Cursor.Size = UDim2.new(0, 64, 0, 64)
  414. end
  415. Abort = true
  416. end)
  417. ChatBox.FocusLost:Connect(function()
  418. if Cursor.Image ~= ShiftLockCursor.Icon and Reading then
  419. Cursor.Image = NormalMouseCursor.Icon
  420. Cursor.Size = NormalMouseCursor.Size
  421. end
  422. Abort = false
  423. end)
  424. end
  425. end
  426.  
  427. local function DoDanceClip()
  428. if ChatBox then
  429. SendText("/")
  430. local Rdm = math.random(15, 25)/100
  431. wait(Rdm/2)
  432. if ChatBox:IsFocused() then
  433. SendText("/e dance2")
  434. end
  435. wait(Rdm/2)
  436. SendKey(13) -- Enter key
  437. wait((2 + 1/6 + 1/6) - Rdm)
  438. end
  439. end
  440.  
  441. LocalPlayer.Chatted:Connect(function(Msg) -- For /e dance2
  442. if Msg:match("/e dance2") then
  443. Dancing = true
  444. end
  445. end)
  446.  
  447. UserInputService.InputBegan:Connect(function(Input, GameProcessed)
  448. if not GameProcessed and Reading then
  449. if Input.UserInputType == Enum.UserInputType.Keyboard then
  450. local Pressed = Input.KeyCode
  451. if Pressed == Enum.KeyCode.L then
  452. FullAbort = true
  453. SendNotification("Replay has been terminated.", 3)
  454. end
  455. end
  456. end
  457. end)
  458.  
  459. local JTOHPlayerScripts = PlayerScripts:FindFirstChild("PlayerScripts")
  460. if JTOHPlayerScripts then
  461. local Limiter = JTOHPlayerScripts:FindFirstChild("Framerate Limiter")
  462. if Limiter then
  463. Limiter.Disabled = true
  464. end
  465. end
  466.  
  467. -- Cursor GUI
  468. local CursorGui = Instance.new("ScreenGui")
  469. if syn then
  470. syn.protect_gui(CursorGui)
  471. end
  472. CursorGui.Name = HttpService:GenerateGUID(false)
  473. CursorGui.Parent = game:GetService("CoreGui")
  474.  
  475. Cursor = Instance.new("ImageLabel")
  476. Cursor.Name = HttpService:GenerateGUID(false)
  477. Cursor.Image = NormalMouseCursor.Icon
  478. Cursor.Size = NormalMouseCursor.Size
  479. Cursor.BorderSizePixel = 0
  480. Cursor.BackgroundTransparency = 1
  481. Cursor.Visible = false
  482. Cursor.Parent = CursorGui
  483.  
  484. -- Zoom Functions
  485. local Self -- Utilized for module zoom functions
  486. local ZoomSpring
  487. local EndLoop = false
  488.  
  489. local function ResetZoom()
  490. LocalPlayer.CameraMinZoomDistance = ZoomMin
  491. LocalPlayer.CameraMaxZoomDistance = ZoomMax
  492. end
  493.  
  494. local function SetZoom(Studs)
  495. local SetToOne = false
  496. if (Studs < 1 and Studs > 0.51) or Studs < 0.49 then
  497. SetToOne = true
  498. end
  499. LocalPlayer.CameraMinZoomDistance = (SetToOne and 1) or Studs
  500. LocalPlayer.CameraMaxZoomDistance = (SetToOne and 1) or Studs
  501. ResetZoom()
  502. end
  503.  
  504. for _, Table in pairs(getgc(true)) do -- Self Table
  505. if type(Table) == "table" then
  506. pcall(function()
  507. if TableCheck(Table) then
  508. if not Self then
  509. local ModuleFunction = Table.EnterFirstPerson
  510. if ModuleFunction and type(ModuleFunction) == "function" then
  511. local ModuleScript = getfenv(ModuleFunction).script
  512. if typeof(ModuleScript) == "Instance" then
  513. if ModuleScript.Name == "ClassicCamera" then
  514. Self = Table
  515. end
  516. end
  517. end
  518. end
  519. if not ZoomSpring then
  520. local ZoomMinValue = Table.minValue
  521. local ModuleFunction_2 = Table.Step
  522. if ZoomMinValue and ModuleFunction_2 and type(ModuleFunction_2) == "function" then
  523. local ModuleScript_2 = getfenv(ModuleFunction_2).script
  524. if typeof(ModuleScript_2) == "Instance" then
  525. if ModuleScript_2.Name == "ZoomController" then
  526. ZoomSpring = Table
  527. end
  528. end
  529. end
  530. end
  531. end
  532. end)
  533. if Self and ZoomSpring then
  534. break
  535. end
  536. end
  537. end
  538.  
  539. assert(Self and ZoomSpring, "Table variable(s) could not be located.")
  540.  
  541. for _, Table in pairs(debug.getregistry()) do
  542. if type(Table) == "table" then
  543. if TableCheck(Table) then
  544. local ZoomFunc = Table.SetCameraToSubjectDistance -- Normal Zoom
  545. if ZoomFunc and type(ZoomFunc) == "function" then
  546. local ModuleScript = getfenv(ZoomFunc).script
  547. if typeof(ModuleScript) == "Instance" then
  548. if ModuleScript.Name == "BaseCamera" then
  549. UpdateZoom = function(Studs)
  550. CurrentZoom = Studs
  551. ZoomSpring.x = Studs or 12.5
  552. if Studs <= 0.52 and not Self.inFirstPerson then
  553. MoveMouse(nil, nil, true) -- DONG IDFK WHAT IM DOING MOMENT
  554. Self:EnterFirstPerson()
  555. CursorMovement = false
  556. MoveMouse(nil, nil, true)
  557. wait(0.1)
  558. mouse1click()
  559. elseif Studs > 0.52 and Self.inFirstPerson then
  560. Self:LeaveFirstPerson()
  561. CursorMovement = true
  562. end
  563. if Studs <= 0.52 or Studs >= 1 then
  564. return ZoomFunc(Self, Studs)
  565. end
  566. end
  567. end
  568. end
  569. end
  570.  
  571. local PopperZoomFunc = Table.Update -- Poppercam Zoom
  572. if PopperZoomFunc and type(PopperZoomFunc) == "function" then
  573. local ModuleScript = getfenv(PopperZoomFunc).script
  574. if typeof(ModuleScript) == "Instance" then
  575. if ModuleScript.Name == "Poppercam" then
  576. for _, Upvalue in pairs(debug.getupvalues(PopperZoomFunc)) do
  577. local CurrentTable = Upvalue
  578. local o = CurrentTable.Update
  579. CurrentTable.Update = function(self, ...)
  580. if Reading then
  581. return CurrentZoom
  582. else
  583. return o(self, ...)
  584. end
  585. end
  586. break
  587. end
  588. end
  589. end
  590. end
  591. end
  592. end
  593. end
  594.  
  595. assert(UpdateZoom, "Could not find zoom updating function")
  596.  
  597. -- UI Initilializing
  598. local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/plusgiant5/Libraries/main/loadstrings/wallyuilib.lua", true))()
  599. local MainWindow = Library:CreateWindow("Replayability")
  600. MainWindow:Bind("Hide Gui", { -- Main Section
  601. flag = "ToggleUI",
  602. kbonly = true,
  603. default = Enum.KeyCode.U
  604. }, function()
  605. local ScreenGui = game:GetService("CoreGui").ScreenGui
  606. if Reading and ScreenGui.Enabled == false then return end
  607. ScreenGui.Enabled = not UIShown
  608. UIShown = not UIShown
  609. SendNotification("Changed UI Visibility", 3)
  610. end)
  611.  
  612. MainWindow:Toggle("Show Notifications", {flag = "ToggleNotifs"}, function(Bool)
  613. ShowNotifications = Bool
  614. end)
  615.  
  616. pcall(function() -- shit ui library
  617. MainWindow.flags.ToggleNotifs = true
  618. game:GetService("CoreGui"):FindFirstChild("Show Notifications", true):WaitForChild("Checkmark", 3).Text = "✓"
  619. end)
  620.  
  621. MainWindow:Dropdown("Mode", {
  622. location = shared;
  623. flag = "Mode";
  624. list = {
  625. "Write",
  626. "Read"
  627. }
  628. }, function(ChosenMode)
  629. if not CanChangeMode() then
  630. print("cant change mode now")
  631. return
  632. end
  633. Mode = ChosenMode
  634. ResetZoom()
  635. SendNotification("Mode changed to: ".. ChosenMode, 3)
  636. end)
  637.  
  638. MainWindow:Section("Write") -- Write Section
  639.  
  640. local function AppendToMain() -- Writing to files
  641. local ToAppend = TempPath
  642. appendfile(CurrentSavePath, ToAppend)
  643. end
  644.  
  645. local function AppendToTemp(Tab)
  646. local Encoded = HttpService:JSONEncode(Tab)
  647. TempPath ..= Encoded..","
  648. end
  649.  
  650. MainWindow:Bind("Begin Replay", {
  651. flag = "BeginReplay",
  652. kbonly = true,
  653. default = Enum.KeyCode.T
  654. }, function()
  655. if Mode ~= "Write" or Saving or RecordStart then return end
  656. if Writing then
  657. Writing = false
  658. Saving = true
  659. local NewLocation = HumanoidRootPart.CFrame
  660. local NewCamCF = Camera.CFrame
  661. local NewCamFC = Camera.Focus
  662. local NewZoom = (NewCamCF.Position - NewCamFC.Position).Magnitude
  663. local responded = false
  664. local inputconnection
  665. function answer(Text)
  666. if not responded then
  667. responded = true
  668. if Text == "YES (p)" then
  669. print("Saving...")
  670. LastMousePositionR = LastMousePositionW
  671. PastLocation = NewLocation
  672. PastCameraLocation = NewCamCF
  673. PastZoom = NewZoom
  674. AppendToMain()
  675. TempPath = ""
  676. SendNotification("Saved", 2)
  677. else
  678. print("Discarded save.")
  679. TempPath = ""
  680. HumanoidRootPart.CFrame = PastLocation
  681. Camera.CFrame = PastCameraLocation
  682. if PastZoom ~= 0 then
  683. SetZoom(PastZoom)
  684. end
  685. ResetZoom()
  686. SendNotification("Discarded", 2)
  687. end
  688. end
  689. Saving = false
  690. if inputconnection then
  691. inputconnection:Disconnect()
  692. end
  693. end
  694. inputconnection = UserInputService.InputBegan:Connect(function(k,v)
  695. if v then
  696. return
  697. end
  698. if k.KeyCode == Enum.KeyCode.F then
  699. answer("NO (f)")
  700. elseif k.KeyCode == Enum.KeyCode.P then
  701. answer("YES (p)")
  702. end
  703. end)
  704. SendNotification("Save Replay?", 15, answer, "NO (f)", "YES (p)")
  705. else
  706. repeat wait() until Humanoid.Parent -- Cuz idk??!?!?
  707. RecordStart = true
  708. SendNotification("Waiting for input.", 2)
  709. WaitForInput()
  710. Writing = true
  711. RecordStart = false
  712. SendNotification("Recording has started.", 3)
  713. end
  714. end)
  715.  
  716. MainWindow:Bind("Goto Checkpoint", {
  717. flag = "GotoCheckpoint",
  718. kbonly = true,
  719. default = Enum.KeyCode.Y
  720. }, function()
  721. if Mode ~= "Write" or Saving then return end
  722. HumanoidRootPart.CFrame = PastLocation
  723. Camera.CFrame = PastCameraLocation
  724. SetZoom(PastZoom)
  725. ResetZoom()
  726. if UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and not CheckMouseLock() and LastMousePositionR[1] then
  727. MoveMouse(LastMousePositionR[1], LastMousePositionR[2])
  728. end
  729. end)
  730.  
  731. MainWindow:Section("Read") -- Read Section
  732. MainWindow:Button("Start", function()
  733. if Reading or Mode ~= "Read" or RecordStart or ReadStart then return end
  734. ReadStart = true
  735. SendNotification("Reading is starting in 2 seconds.", 3)
  736. delay(2, function()
  737. Reading = true
  738. ReadStart = false
  739. end)
  740. end)
  741.  
  742. MainWindow:Section("Other") -- Other Section
  743. MainWindow:Button("Disable Killbricks", function()
  744. local n = 0
  745. for _,v in pairs(workspace:GetDescendants()) do
  746. if (v.Name == "kills" or v.Name == "instakills" or v.Name == "poisons" or v.Name == "ouch") and v.Parent.CanTouch then
  747. v.Parent.CanTouch = false
  748. n += 1
  749. end
  750. end
  751. SendNotification("Disabled "..tostring(n).." killbricks.", 3)
  752. end)
  753. MainWindow:Button("Count Frames", function()
  754. local frames = #HttpService:JSONDecode(readfile(PlaceId.."\\Testing.lua").."1]")
  755. SendNotification("This replay has "..tostring(frames).." frames ("..tostring(math.floor(frames/60*100+.5)/100).." seconds long at constant 60 fps)", 10)
  756. end)
  757. MainWindow:Box("Start at frame: ", {default = "0"}, function(frame)
  758. StartFrame = tonumber(frame)
  759. Index = StartFrame
  760. SendNotification("Reading will now start at frame "..frame, 3)
  761. end)
  762.  
  763. -- Main Loops
  764. -- WRITE
  765. local function Write()
  766. while true do
  767. if not Writing or Saving then
  768. wait()
  769. else
  770. local t = tick()
  771. local StateTypeValue = Humanoid and Humanoid.Parent and Humanoid:GetState().Value
  772. if not SentDeadSignal then
  773. if not Hooked then
  774. HookHumanoid()
  775. Hooked = true
  776. end
  777. local s,e = pcall(function()
  778. Character.Head.CanCollide = true
  779. local CamCFrame = Camera.CFrame
  780. local CamFocus = Camera.Focus
  781. local Zoom = (CamCFrame.Position - CamFocus.Position).Magnitude
  782. local RunSpeed = RunQueue[1]
  783. local ClimbSpeed = ClimbQueue[1]
  784. local WriteTable = {}
  785. WriteTable[1] = CFrameToTable(HumanoidRootPart.CFrame)
  786. WriteTable[2] = CFrameToTable(CamCFrame)
  787. WriteTable[3] = Zoom
  788. WriteTable[4] = Shorten(RunSpeed) or false
  789. if RunSpeed then
  790. table.remove(RunQueue, 1)
  791. end
  792. WriteTable[5] = Shorten(ClimbSpeed) or false
  793. if ClimbSpeed then
  794. table.remove(ClimbQueue, 1)
  795. end
  796. WriteTable[6] = CheckMouseLock()
  797. WriteTable[7] = StateTypeValue
  798. local MousePosition = {
  799. Mouse.X, Mouse.Y
  800. }
  801. WriteTable[8] = MousePosition
  802. LastMousePositionW = MousePosition
  803. WriteTable[9] = Dancing
  804. if Dancing then
  805. Dancing = false
  806. end
  807. AppendToTemp(WriteTable)
  808. end)
  809. if not s then
  810. print(e)
  811. end
  812. end
  813. RunService.Stepped:Wait()
  814. repeat until (t + (1/FPS)) < tick()
  815.  
  816. print(StateTypeValue)
  817. if StateTypeValue == 15 and not SentDeadSignal then -- Dead
  818. --print("w1")
  819. SentDeadSignal = true
  820. else
  821. if StateTypeValue and SentDeadSignal then -- make sure the humanoid exists, and SentDeadSignal isnt already false
  822. SentDeadSignal = false
  823. --print("w2")
  824. end
  825. end
  826. end
  827. end
  828. end
  829. coroutine.wrap(Write)()
  830.  
  831. -- READ
  832. local function Read()
  833. while true do
  834. if not Reading then
  835. wait()
  836. else
  837. local t = tick()
  838. if not ReadTable then
  839. local Success, Return = pcall(function()
  840. return HttpService:JSONDecode(readfile(PlaceId.. "\\Testing.lua") .. "1]")--[1]
  841. end)
  842. if not Success then
  843. Reading = false
  844. error("Error parsing the JSON file")
  845. end
  846. if Humanoid.Health <= 0 then
  847. Reading = false
  848. end
  849. ReadTable = Return
  850. Humanoid.AutoRotate = false
  851. Humanoid.Died:Connect(function()
  852. if Reading then
  853. --FullAbort = true
  854. end
  855. end)
  856. local CharAddedConnection
  857. CharacterAddedConnection = LocalPlayer.CharacterAdded:Connect(function()
  858. if Reading then
  859. --FullAbort = true
  860. CharacterAddedConnection:Disconnect()
  861. end
  862. end)
  863. UserInputService.MouseIconEnabled = not ReplicateCursor
  864. Cursor.Visible = ReplicateCursor
  865. --local FirstLocation = ReadTable[1][1]
  866. --WalkToPoint(Vector3.new(FirstLocation.X, FirstLocation.Y, FirstLocation.Z))
  867. end
  868. local CurrentReadTable = ReadTable[Index]
  869. if not CurrentReadTable or type(CurrentReadTable) ~= "table" or FullAbort then
  870. local LastIndex = ReadTable[Index - 1]
  871. if LastIndex then
  872. local LastMousePositionEnd = LastIndex[8]
  873. if LastMousePositionEnd and LastMousePositionEnd[1] then
  874. MoveMouse(LastMousePositionEnd[1], LastMousePositionEnd[2])
  875. end
  876. end
  877. if Cursor then
  878. Cursor.Visible = false
  879. end
  880. UserInputService.MouseIconEnabled = true
  881. Reading = false
  882. FullAbort = false
  883. ReadTable = nil
  884. PreviousRunSpeed = nil
  885. Index = StartFrame
  886. workspace.Gravity = DefaultGravity
  887. Humanoid.AutoRotate = true
  888. Humanoid.UseJumpPower = UseJumpPower -- Sets it to whatever the game set it to by default
  889. Humanoid.JumpHeight = OldJumpHeight
  890. CurrentZoom = 0
  891. continue
  892. end
  893.  
  894. workspace.Gravity = 0
  895.  
  896. if Abort then
  897. RunFunction(0, true)
  898. workspace.Gravity = DefaultGravity
  899. repeat wait() until not Abort
  900. wait(math.random(15, 25)/10)
  901. if PreviousRunSpeed then
  902. RunFunction(PreviousRunSpeed, true)
  903. end
  904. end
  905.  
  906. if Humanoid.UseJumpPower then
  907. Humanoid.UseJumpPower = false
  908. Humanoid.JumpHeight = 0
  909. end
  910.  
  911. local HumanoidRootPartLocation = TableToCFrame(CurrentReadTable[1])
  912. local CameraLocation = TableToCFrame(CurrentReadTable[2])
  913. local Zoom = CurrentReadTable[3]
  914. local RunSpeed = tonumber(CurrentReadTable[4])
  915. local ClimbSpeed = tonumber(CurrentReadTable[5])
  916. local IsMouseLocked = CurrentReadTable[6]
  917. local StateTypeValue = CurrentReadTable[7]
  918. local MousePosition = (ReplicateCursor and CurrentReadTable[8]) or nil
  919. local DanceClipping = CurrentReadTable[9] or (CurrentReadTable[8] == true and CurrentReadTable[8])
  920. local _, YAxisCameraRotation = CameraLocation:ToEulerAnglesYXZ()
  921. local XAxisCharacterRotation, YAxisCharacterRotation, ZAxisCharacterRotation = HumanoidRootPartLocation:ToEulerAnglesYXZ()
  922.  
  923. Camera.CFrame = CameraLocation
  924. UpdateZoom(Zoom)
  925. HumanoidRootPart.Velocity = Vector3.new()
  926.  
  927. if (IsMouseLocked or (Zoom <= 0.51 and Zoom >= 0.49)) and StateTypeValue ~= 0 and StateTypeValue ~= 2 then -- Shiftlocked, isfirstperson, isfallingdown and isgettingbackup respectively
  928. HumanoidRootPart.CFrame = HumanoidRootPartLocation * CFrame.Angles(0, -YAxisCharacterRotation + YAxisCameraRotation, 0)
  929. else
  930. HumanoidRootPart.CFrame = HumanoidRootPartLocation
  931. end
  932.  
  933. for _, BasePart in pairs(Character:GetChildren()) do
  934. if BasePart:IsA("BasePart") then
  935. if BasePart.CanCollide and StateTypeValue == 5 then
  936. --BasePart.CanCollide = false
  937. end
  938. end
  939. end
  940.  
  941. --[[ OLD GRAVITY MODIFIER
  942. if StateTypeValue == 5 and workspace.Gravity ~= 0 then
  943. workspace.Gravity = 0
  944. elseif StateTypeValue ~= 5 and workspace.Gravity ~= 196.2 then
  945. workspace.Gravity = 196.2
  946. end
  947. ]]
  948.  
  949. if MousePosition and MousePosition[1] then
  950. SetFakeCursorPosition(MousePosition[1], MousePosition[2])
  951. if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
  952. VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
  953. end
  954. end
  955. --[[ OLD MOUSE POSITIONING
  956. if MousePosition and UserInputService.MouseBehavior ~= Enum.MouseBehavior.LockCenter and CursorMovement and not CheckMouseLock() and MousePosition[1] then
  957. MoveMouse(MousePosition[1], MousePosition[2])
  958. elseif UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
  959. VirtualInputManager:SendMouseMoveEvent(MousePosition[1], MousePosition[2], workspace)
  960. end
  961. ]]
  962.  
  963. if (IsMouseLocked and not CheckMouseLock()) or (not IsMouseLocked and CheckMouseLock()) then
  964. ToggleMouseLock()
  965. mouse1click()
  966. end
  967.  
  968. local CurrentLocked = CheckMouseLock()
  969. Cursor.Image = CurrentLocked and ShiftLockCursor.Icon or NormalMouseCursor.Icon
  970. Cursor.Size = CurrentLocked and ShiftLockCursor.Size or NormalMouseCursor.Size
  971. --[[ ANTI SERVER-SIDED DETECTION
  972. if RunSpeed then
  973. HumanoidRootPart.Velocity = Vector3.new(RunSpeed/2, 0, 0)
  974. else
  975. HumanoidRootPart.Velocity = Vector3.new(HumanoidRootPart.Velocity.X, 0, 0)
  976. end
  977. ]]
  978.  
  979. if StateTypeValue ~= OldState then
  980.  
  981. if StateTypeValue == 3 then -- Jumping
  982. Humanoid.Jump = true
  983. else
  984. if StateTypeValue == 15 then
  985. -- press keys Esc+R+Enter then reset gravity
  986. keypress(0x1B)
  987. wait()
  988. keyrelease(0x1B)
  989. wait(math.random(15,27)/100)
  990. keypress(0x52)
  991. wait()
  992. keyrelease(0x52)
  993. wait(math.random(15,27)/100)
  994. keypress(0x0D)
  995. wait()
  996. keyrelease(0x0D)
  997. wait(math.random(15,27)/100)
  998. workspace.Gravity = DefaultGravity
  999. end
  1000. Humanoid:ChangeState(StateTypeValue)
  1001. end
  1002. OldState = StateTypeValue
  1003. end
  1004.  
  1005. if (StateTypeValue == 8 or StateTypeValue == 10) and RunSpeed then
  1006. RunFunction(RunSpeed, true)
  1007. PreviousRunSpeed = RunSpeed
  1008. end
  1009.  
  1010. if StateTypeValue == 12 and ClimbSpeed then
  1011. ClimbFunction(ClimbSpeed, true)
  1012. PreviousClimbSpeed = ClimbSpeed
  1013. end
  1014.  
  1015. if DanceClipping then
  1016. DoDanceClip()
  1017. end
  1018.  
  1019. Index += 1
  1020. RunService.Stepped:Wait()
  1021. repeat until (t + (1/FPS)) < tick()
  1022.  
  1023. if StateTypeValue == 15 then -- Dead
  1024. -- Wait until player fully respawns before replaying another frame
  1025. --print("r1")
  1026. LocalPlayer.CharacterAdded:Wait()
  1027. while not ClimbFunction do
  1028. RunService.Stepped:Wait()
  1029. end
  1030. wait(math.random(15,30)/100)
  1031. --print("r2")
  1032. end
  1033. end
  1034. end
  1035. end
  1036. coroutine.wrap(Read)()
  1037.  
  1038. -- Loading checkpoint
  1039. local placefile = readfile(PlaceId.. "\\Testing.lua")
  1040. if placefile then
  1041. local data = HttpService:JSONDecode(placefile.."1]")
  1042. if #data > 1 then
  1043. local lastframe = data[#data-1]
  1044. PastLocation = TableToCFrame(lastframe[1])
  1045. PastCameraLocation = TableToCFrame(lastframe[2])
  1046. PastZoom = lastframe[3]
  1047. LastMousePositionR = lastframe[8]
  1048. end
  1049. end
  1050.  
  1051. SendNotification("Replayability v1.7.3 loaded!", 3)
  1052.  
  1053. game:GetService("GuiService").ErrorMessageChanged:Connect(function()
  1054. FullAbort = true
  1055. end)
  1056.  
  1057. --wait(.25)
  1058. --loadstring(game:HttpGet("https://raw.githubusercontent.com/plusgiant5/Libraries/main/loadstrings/animfix.lua", true))()
  1059.  
  1060. getgenv().Ran = true
Advertisement
Add Comment
Please, Sign In to add comment