Advertisement
Liu-2

Time Rewind - [ Roblox ]

Jul 9th, 2019
9,376
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.00 KB | None | 0 1
  1. --- [[ Simple Time Rewind ]] ---
  2. -- by fo43123
  3.  
  4. local me = game.Players.LocalPlayer
  5. local mouse = me:GetMouse()
  6. local char = me.Character
  7. local hum = char:FindFirstChild('Humanoid')
  8. local hd = char:FindFirstChild('Head')
  9. local ts = char:FindFirstChild('Torso') or char:FindFirstChild('UpperTorso')
  10. local ra = char:FindFirstChild('Right Arm') or char:FindFirstChild('RightUpperArm')
  11. local la = char:FindFirstChild('Left Arm') or char:FindFirstChild('LeftUpperArm')
  12. local rl = char:FindFirstChild('Right Leg') or char:FindFirstChild('RightUpperLeg')
  13. local ll = char:FindFirstChild('Left Leg') or char:FindFirstChild('LeftUpperLeg')
  14. local root = char:FindFirstChild('HumanoidRootPart')
  15. local rj = root:FindFirstChild('RootJoint')
  16. local rs = ts:FindFirstChild('Right Shoulder')
  17. local ls = ts:FindFirstChild('Left Shoulder')
  18. local rh = ts:FindFirstChild('Right Hip')
  19. local lh = ts:FindFirstChild('Left Hip')
  20. local nk = ts:FindFirstChild('Neck')
  21. local anim = char:FindFirstChild('Animate')
  22. local base = workspace:FindFirstChild('Baseplate') or workspace:FindFirstChild('Base')
  23. local cantimerewind = true
  24. local cooldown = false
  25. local selfrewind = true
  26. local cc = workspace.CurrentCamera
  27. local cos = math.cos
  28. local sin = math.sin
  29. local rad = math.rad
  30. local rand = math.random
  31. local cfn = CFrame.new
  32. local cfa = CFrame.Angles
  33. local v3 = Vector3.new
  34. local str = string
  35. local past = {}
  36. local lastpast = {}
  37. local sine = 0
  38. local rewind = Instance.new('Sound', hd)
  39. local onrewind = Instance.new('Sound', workspace.CurrentCamera)
  40. onrewind.Looped = true
  41. onrewind.Volume = 10
  42. onrewind.SoundId = 'rbxassetid://2061143306'
  43. rewind.SoundId = 'rbxassetid://864569342'
  44. rewind.Name = 'trewind'
  45. rewind.Volume = 1
  46. rewind.PlaybackSpeed = 1.25
  47. hum.WalkSpeed = 23
  48. effects = Instance.new('Folder', char)
  49. effects.Name = 'Effects'
  50. print([[
  51.     -- // Moves
  52.     R - Rewind
  53.     ]])
  54.  
  55. ArtificialHB = Instance.new('BindableEvent', script)
  56. ArtificialHB.Name = 'Heartbeat'
  57. script:WaitForChild('Heartbeat')
  58.  
  59. frame = 1 / 60
  60. tf = 0
  61. allowframeloss = false
  62. tossremainder = false
  63. lastframe = tick()
  64. script.Heartbeat:Fire()
  65.  
  66. game:GetService('RunService').Heartbeat:connect(function(s, p)
  67.     tf = tf + s
  68.     if tf >= frame then
  69.         if allowframeloss then
  70.             script.Heartbeat:Fire()
  71.             lastframe = tick()
  72.         else
  73.             for i = 1, math.floor(tf / frame) do
  74.                 script.Heartbeat:Fire()
  75.             end
  76.             lastframe = tick()
  77.         end
  78.         if tossremainder then
  79.             tf = 0
  80.         else
  81.             tf = tf - frame * math.floor(tf / frame)
  82.         end
  83.     end
  84. end)
  85.  
  86. function swait(t)
  87.     if t == 0 or t == nil then
  88.         script.Heartbeat.Event:Wait()
  89.     else
  90.         for i = 0, t do
  91.             script.Heartbeat.Event:Wait()
  92.         end
  93.     end
  94. end
  95.  
  96. function sound(id, parent, vol, pitch, timepos)
  97.     local s = Instance.new('Sound')
  98.     s.Parent = parent
  99.     s.SoundId = id
  100.     s.Volume = vol
  101.     s.PlaybackSpeed = pitch
  102.     s.TimePosition = timepos
  103.     s:Play()
  104.     game.Debris:AddItem(s, s.PlaybackSpeed + 5)
  105. end
  106.  
  107. function camshake(duration, intensity)
  108.     coroutine.wrap(function()
  109.         for i = 0, duration*60 do
  110.             hum.CameraOffset = v3(rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10), (intensity*10))/10)
  111.             swait()
  112.         end
  113.         hum.CameraOffset = v3(0, 0, 0)
  114.     end)()
  115. end
  116.  
  117. function readyrewind()
  118.     cantimerewind = false
  119.     cooldown = true
  120.     onrewind:Play()
  121.     for i,v in pairs(workspace:GetDescendants()) do
  122.         if v:IsA('BasePart') then
  123.             local lastpos = v.CFrame
  124.             table.insert(past, {part = v, change = lastpos})
  125.         end
  126.         if v.Parent then
  127.             local lastparent2 = v.Parent
  128.             table.insert(lastpast, {part2 = v, change4 = lastparent2})
  129.         end
  130.         if v:IsA('Camera') then
  131.             local lastcam = v.CFrame
  132.             table.insert(past, {cam = v, change3 = lastcam})
  133.         end
  134.         if v:IsA('Sound') then
  135.             if v ~= rewind then
  136.                 local lastsongpos = v.TimePosition
  137.                 table.insert(past, {sound = v, pchange = lastsongpos})
  138.             end
  139.         end
  140.         if v:IsA('Humanoid') then
  141.             local lasthp = v.Health
  142.             local always = lasthp
  143.             table.insert(past, {health = v, hchange = lasthp})
  144.         end
  145.     end
  146.     newpast = workspace.DescendantAdded:Connect(function(v)
  147.         if v:IsA('BasePart') then
  148.             local lastpos = v.CFrame
  149.             local lastparent = v.Parent
  150.             table.insert(past, {part = v, change = lastpos, change4 = lastparent})
  151.         end
  152.         if v.Parent then
  153.             local lastparent2 = v.Parent
  154.             table.insert(lastpast, {part2 = v, change4 = lastparent2})
  155.         end
  156.         if v:IsA('Camera') then
  157.             local lastcampos = v.CFrame
  158.             table.insert(past, {cam = v, change3 = lastcampos})
  159.         end
  160.         if v:IsA('Sound') then
  161.             if v ~= rewind then
  162.                 local lastsongpos = v.TimePosition
  163.                 table.insert(past, {sound = v, pchange = lastsongpos})
  164.             end
  165.         end
  166.         if v:IsA('Humanoid') then
  167.             local lasthp = v.Health
  168.             local always = lasthp
  169.             table.insert(past, {health = v, hchange = lasthp})
  170.         end
  171.     end)
  172. end
  173.  
  174. function timerewind()
  175.     if cooldown then
  176.     rewind:Play()
  177.     sine = 0
  178.     onrewind:Stop()
  179.     coroutine.wrap(function()
  180.     local cce = Instance.new('ColorCorrectionEffect', game.Lighting)
  181.     local blur = Instance.new('BlurEffect', game.Lighting)
  182.     local effect2 = Instance.new('Part', effects)
  183.     local effect3 = Instance.new('Part', effects)
  184.     effect3.Shape = 'Ball'
  185.     effect3.Material = 'ForceField'
  186.     effect3.Anchored = true
  187.     effect3.CanCollide = false
  188.     effect3.Name = 'eff3'
  189.     effect3.BrickColor = BrickColor.new('Really red')
  190.     effect3.Size = v3(30, 30, 30)
  191.     effect3.Transparency = 0
  192.     effect2.CastShadow = false
  193.     effect2.Shape = 'Ball'
  194.     effect2.BrickColor = BrickColor.new('Bright red')
  195.     effect2.Material = 'ForceField'
  196.     effect2.Name = 'eff2'
  197.     effect2.Anchored = true
  198.     effect2.CanCollide = false
  199.     effect2.Size = v3(50, 50, 50)
  200.     effect2.Transparency = 0
  201.     cantimerewind = true
  202.     for i,v in pairs(past) do
  203.         pcall(function()
  204.             v.part.CFrame = v.change
  205.         end)
  206.         pcall(function()
  207.             v.cam.CFrame = v.change3
  208.         end)
  209.         pcall(function()
  210.             v.sound.TimePosition = v.pchange
  211.         end)
  212.         pcall(function()
  213.             v.health.Health = v.hchange
  214.         end)
  215.     end
  216.     for i,v in pairs(lastpast) do
  217.         pcall(function()
  218.             v.part2.Parent = v.change4
  219.         end)
  220.     end
  221.     pcall(function()
  222.         newpast:Disconnect()
  223.     end)
  224.     coroutine.wrap(function()
  225.         for i = 1, 1000 do
  226.             effect2.CFrame = ts.CFrame
  227.             effect3.CFrame = ts.CFrame
  228.             blur.Size = v3(blur.Size, 0, 0):lerp(v3(0, 0, 0), .010).X
  229.             cce.TintColor = cce.TintColor:lerp(Color3.fromRGB(255, 0, 0), 0.050)
  230.             effect2.Transparency = effect2.Transparency + 0.020
  231.             effect3.Transparency = effect3.Transparency + 0.020
  232.             effect2.Size = effect2.Size:lerp(v3(0, 0, 0), 0.050)
  233.             effect3.Size = effect3.Size:lerp(v3(0, 0, 0), 0.030)
  234.             if effect2.Transparency >= 1 then
  235.                 effect2:Destroy()
  236.             end
  237.             if effect3.Transparency >= 1 then
  238.                 effect3:Destroy()
  239.             end
  240.             swait()
  241.         end
  242.     end)()
  243.     wait(1)
  244.     blur:Destroy()
  245.     cce:Destroy()
  246.     end)()
  247.     wait(1.5) -- cooldown
  248.     past = {}
  249.     cooldown = false
  250.     end
  251. end
  252.  
  253. mouse.KeyDown:connect(function(key)
  254.     if str.lower(key) == 'r' and cantimerewind and cooldown == false then
  255.         readyrewind()
  256.     elseif str.lower(key) == 'r' and cantimerewind == false and cooldown then
  257.         timerewind()
  258.     end
  259. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement