plytalent

ah it rewind time

Jul 26th, 2020 (edited)
2,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. local events=nil
  2. local rewinding=false
  3. local frames=0
  4. local plrs = game:GetService("Players")
  5. local plr = plrs.LocalPlayer
  6. local storepos={}
  7. local storehp={}
  8. local storemaxhp = {}
  9. events=game:GetService("RunService").RenderStepped:Connect(function()
  10.     if not rewinding then
  11.         frames = frames +1
  12.         if not storepos[frames] then
  13.             if plr.Character:FindFirstChild("HumanoidRootPart") then
  14.                 storepos[frames] = plr.Character.HumanoidRootPart.CFrame
  15.             end
  16.         end
  17.     end
  18. end)
  19.  
  20. function waitframe(frame)
  21.     for i = 1 , frames do
  22.         game:GetService("RunService").RenderStepped:Wait()
  23.     end
  24. end
  25.  
  26. function ahhhh_it_rewind_time(targetframe)
  27.     if targetframe then
  28.         if not rewinding then
  29.             rewinding = true
  30.             print(targetframe)
  31.             ws=plr.Character.Humanoid.WalkSpeed
  32.             jp=plr.Character.Humanoid.JumpPower
  33.             if #storepos < targetframe then
  34.                 targetframe = #storepos
  35.             end
  36.             print(targetframe,frames)
  37.             maxrewindedframe = frames - targetframe
  38.             if maxrewindedframe < 1 then
  39.                 maxrewindedframe = 1
  40.             end
  41.             frames = maxrewindedframe
  42.             print("for i=".. tostring(targetframe)..",".. tostring(maxrewindedframe))
  43.             local index=1
  44.             for i=#storepos, maxrewindedframe ,-1 do
  45.                 print(i)
  46.                 index=i
  47.                 game:GetService("RunService").RenderStepped:Wait()
  48.                 plr.Character.HumanoidRootPart.CFrame = storepos[i]
  49.                 plr.Character.HumanoidRootPart.Anchored = true
  50.                 plr.Character.Humanoid.WalkSpeed = 0
  51.                 plr.Character.Humanoid.JumpPower = 0
  52.             end
  53.             for i= index+1,#storepos do
  54.                 storepos[i] = nil
  55.             end
  56.             plr.Character.Humanoid.WalkSpeed = ws
  57.             plr.Character.Humanoid.JumpPower = jp
  58.             plr.Character.HumanoidRootPart.Anchored = false
  59.             plr.Character.HumanoidRootPart.CFrame = storepos[index]
  60.             rewinding = false
  61.             frames=index
  62.         end
  63.     end
  64. end
  65. plr.Chatted:Connect(function(msg)
  66.     if string.sub(msg,1,3) =="/e " then
  67.         msg = string.sub(msg,4)
  68.     end
  69.     if string.sub(msg,1,8) =="Yud_Bet:" then
  70.         print("Called Yud Bet")
  71.         ahhhh_it_rewind_time(tonumber(string.sub(msg,9)) )
  72.     end
  73. end)
Add Comment
Please, Sign In to add comment