carlosname

Untitled

Jan 13th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 = 0.05
  47. effects = Instance.new('Folder', char)
  48. effects.Name = 'Effects'
  49. print([[
  50.     -- // Moves
  51.     C - Rewind
  52.     ]])
  53.  
  54. ArtificialHB = Instance.new('BindableEvent', script)
  55. ArtificialHB.Name = 'Heartbeat'
  56. script:WaitForChild('Heartbeat')
  57.  
  58. frame = 1 / 60
  59. tf = 0
  60. allowframeloss = false
  61. tossremainder = false
  62. lastframe = tick()
  63. script.Heartbeat:Fire()
  64.  
  65. game:GetService('RunService').Heartbeat:connect(function(s, p)
  66.     tf = tf + s
  67.     if tf >= frame then
  68.         if allowframeloss then
  69.             script.Heartbeat:Fire()
  70.             lastframe = tick()
  71.         else
  72.             for i = 1, math.floor(tf / frame) do
  73.                 script.Heartbeat:Fire()
  74.             end
  75.             lastframe = tick()
  76.         end
  77.         if tossremainder then
  78.             tf = 0
  79.         else
  80.             tf = tf - frame * math.floor(tf / frame)
  81.         end
  82.     end
  83. end)
  84.  
  85. function swait(t)
  86.     if t == 0 or t == nil then
  87.         script.Heartbeat.Event:Wait()
  88.     else
  89.         for i = 0, t do
  90.             script.Heartbeat.Event:Wait()
  91.         end
  92.     end
  93. end
  94.  
  95. function sound(id, parent, vol, pitch, timepos)
  96.     local s = Instance.new('Sound')
  97.     s.Parent = parent
  98.     s.SoundId = id
  99.     s.Volume = vol
  100.     s.PlaybackSpeed = pitch
  101.     s.TimePosition = timepos
  102.     s:Play()
  103.     game.Debris:AddItem(s, s.PlaybackSpeed + 5)
  104. end
  105.  
  106. function camshake(duration, intensity)
  107.     coroutine.wrap(function()
  108.         for i = 0, duration*60 do
  109.             hum.CameraOffset = v3(rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10), (intensity*10))/10)
  110.             swait()
  111.         end
  112.         hum.CameraOffset = v3(0, 0, 0)
  113.     end)()
  114. end
  115.  
  116. function readyrewind()
  117.     cantimerewind = false
  118.     cooldown = true
  119.     onrewind:Play()
  120.     for i,v in pairs(workspace:GetDescendants()) do
  121.         if v:IsA('BasePart') then
  122.             local lastpos = v.CFrame
  123.             table.insert(past, {part = v, change = lastpos})
  124.         end
  125.         if v.Parent then
  126.             local lastparent2 = v.Parent
  127.             table.insert(lastpast, {part2 = v, change4 = lastparent2})
  128.         end
  129.         if v:IsA('Camera') then
  130.             local lastcam = v.CFrame
  131.             table.insert(past, {cam = v, change3 = lastcam})
  132.         end
  133.         if v:IsA('Sound') then
  134.             if v ~= rewind then
  135.                 local lastsongpos = v.TimePosition
  136.                 table.insert(past, {sound = v, pchange = lastsongpos})
  137.             end
  138.         end
  139.         if v:IsA('Humanoid') then
  140.             local lasthp = v.Health
  141.             local always = lasthp
  142.             table.insert(past, {health = v, hchange = lasthp})
  143.         end
  144.     end
  145.     newpast = workspace.DescendantAdded:Connect(function(v)
  146.         if v:IsA('BasePart') then
  147.             local lastpos = v.CFrame
  148.             local lastparent = v.Parent
  149.             table.insert(past, {part = v, change = lastpos, change4 = lastparent})
  150.         end
  151.         if v.Parent then
  152.             local lastparent2 = v.Parent
  153.             table.insert(lastpast, {part2 = v, change4 = lastparent2})
  154.         end
  155.         if v:IsA('Camera') then
  156.             local lastcampos = v.CFrame
  157.             table.insert(past, {cam = v, change3 = lastcampos})
  158.         end
  159.         if v:IsA('Sound') then
  160.             if v ~= rewind then
  161.                 local lastsongpos = v.TimePosition
  162.                 table.insert(past, {sound = v, pchange = lastsongpos})
  163.             end
  164.         end
  165.         if v:IsA('Humanoid') then
  166.             local lasthp = v.Health
  167.             local always = lasthp
  168.             table.insert(past, {health = v, hchange = lasthp})
  169.         end
  170.     end)
  171. end
  172.  
  173. function timerewind()
  174.     if cooldown then
  175.     rewind:Play()
  176.     sine = 0
  177.     onrewind:Stop()
  178.     coroutine.wrap(function()
  179.     local blur = Instance.new('BlurEffect', game.Lighting)
  180.     local effect2 = Instance.new('Part', effects)
  181.     local effect3 = Instance.new('Part', effects)
  182.     effect3.Shape = 'Ball'
  183.     effect3.Material = 'ForceField'
  184.     effect3.Anchored = true
  185.     effect3.CanCollide = false
  186.     effect3.Name = 'eff3'
  187.     effect3.BrickColor = BrickColor.new('Really red')
  188.     effect3.Size = v3(30, 30, 30)
  189.     effect3.Transparency = 0
  190.     effect2.CastShadow = false
  191.     effect2.Shape = 'Ball'
  192.     effect2.BrickColor = BrickColor.new('Bright red')
  193.     effect2.Material = 'ForceField'
  194.     effect2.Name = 'eff2'
  195.     effect2.Anchored = true
  196.     effect2.CanCollide = false
  197.     effect2.Size = v3(50, 50, 50)
  198.     effect2.Transparency = 0
  199.     cantimerewind = true
  200.     for i,v in pairs(past) do
  201.         pcall(function()
  202.             v.part.CFrame = v.change
  203.         end)
  204.         pcall(function()
  205.             v.cam.CFrame = v.change3
  206.         end)
  207.         pcall(function()
  208.             v.sound.TimePosition = v.pchange
  209.         end)
  210.         pcall(function()
  211.             v.health.Health = v.hchange
  212.         end)
  213.     end
  214.     for i,v in pairs(lastpast) do
  215.         pcall(function()
  216.             v.part2.Parent = v.change4
  217.         end)
  218.     end
  219.     pcall(function()
  220.         newpast:Disconnect()
  221.     end)
  222.     coroutine.wrap(function()
  223.         for i = 1, 1000 do
  224.             effect2.CFrame = ts.CFrame
  225.             effect3.CFrame = ts.CFrame
  226.             blur.Size = v3(blur.Size, 0, 0):lerp(v3(0, 0, 0), .010).X
  227.             effect2.Transparency = effect2.Transparency + 0.020
  228.             effect3.Transparency = effect3.Transparency + 0.020
  229.             effect2.Size = effect2.Size:lerp(v3(0, 0, 0), 0.050)
  230.             effect3.Size = effect3.Size:lerp(v3(0, 0, 0), 0.030)
  231.             if effect2.Transparency >= 1 then
  232.                 effect2:Destroy()
  233.             end
  234.             if effect3.Transparency >= 1 then
  235.                 effect3:Destroy()
  236.             end
  237.             swait()
  238.         end
  239.     end)()
  240.     wait(1)
  241.     blur:Destroy()
  242.     end)()
  243.     wait(1.5) -- cooldown
  244.     past = {}
  245.     cooldown = false
  246.     end
  247. end
  248.  
  249. mouse.KeyDown:connect(function(key)
  250.     if str.lower(key) == 'c' and cantimerewind and cooldown == false then
  251.         readyrewind()
  252.     elseif str.lower(key) == 'c' and cantimerewind == false and cooldown then
  253.         timerewind()
  254.     end
  255. end)
Advertisement
Add Comment
Please, Sign In to add comment