SHOW:
|
|
- or go back to the newest paste.
| 1 | --- [[ Simple Time Rewind ]] --- | |
| 2 | - | -- by fo43123 |
| 2 | + | -- by fo43123, edited by dinsfire34 |
| 3 | -- original: https://pastebin.com/J4SZ8VC7 | |
| 4 | - | local me = game.Players.LocalPlayer |
| 4 | + | |
| 5 | - | local mouse = me:GetMouse() |
| 5 | + | local mePlayer = game.Players.LocalPlayer |
| 6 | - | local char = me.Character |
| 6 | + | local meChar = game.workspace.LocalPlayer |
| 7 | local mouse = mePlayer:GetMouse() | |
| 8 | local char = meChar | |
| 9 | local hum = char:FindFirstChild('Humanoid')
| |
| 10 | local hd = char:FindFirstChild('Head')
| |
| 11 | local ts = char:FindFirstChild('Torso') or char:FindFirstChild('UpperTorso')
| |
| 12 | local ra = char:FindFirstChild('Right Arm') or char:FindFirstChild('RightUpperArm')
| |
| 13 | local la = char:FindFirstChild('Left Arm') or char:FindFirstChild('LeftUpperArm')
| |
| 14 | local rl = char:FindFirstChild('Right Leg') or char:FindFirstChild('RightUpperLeg')
| |
| 15 | local ll = char:FindFirstChild('Left Leg') or char:FindFirstChild('LeftUpperLeg')
| |
| 16 | local root = char:FindFirstChild('HumanoidRootPart')
| |
| 17 | local rj = root:FindFirstChild('RootJoint')
| |
| 18 | local rs = ts:FindFirstChild('Right Shoulder')
| |
| 19 | local ls = ts:FindFirstChild('Left Shoulder')
| |
| 20 | local rh = ts:FindFirstChild('Right Hip')
| |
| 21 | local lh = ts:FindFirstChild('Left Hip')
| |
| 22 | local nk = ts:FindFirstChild('Neck')
| |
| 23 | local anim = char:FindFirstChild('Animate')
| |
| 24 | local base = workspace:FindFirstChild('Baseplate') or workspace:FindFirstChild('Base')
| |
| 25 | local cantimerewind = true | |
| 26 | local cooldown = false | |
| 27 | local selfrewind = true | |
| 28 | local cc = workspace.CurrentCamera | |
| 29 | local cos = math.cos | |
| 30 | local sin = math.sin | |
| 31 | local rad = math.rad | |
| 32 | local rand = math.random | |
| 33 | local cfn = CFrame.new | |
| 34 | local cfa = CFrame.Angles | |
| 35 | local v3 = Vector3.new | |
| 36 | local str = string | |
| 37 | local past = {}
| |
| 38 | local lastpast = {}
| |
| 39 | local sine = 0 | |
| 40 | local rewind = Instance.new('Sound', hd)
| |
| 41 | local onrewind = Instance.new('Sound', workspace.CurrentCamera)
| |
| 42 | onrewind.Looped = true | |
| 43 | onrewind.Volume = 10 | |
| 44 | onrewind.SoundId = 'rbxassetid://2061143306' | |
| 45 | rewind.SoundId = 'rbxassetid://864569342' | |
| 46 | rewind.Name = 'trewind' | |
| 47 | rewind.Volume = 1 | |
| 48 | rewind.PlaybackSpeed = 1.25 | |
| 49 | hum.WalkSpeed = 23 | |
| 50 | - | print([[ |
| 50 | + | |
| 51 | - | -- // Moves |
| 51 | + | |
| 52 | - | R - Rewind |
| 52 | + | |
| 53 | - | ]]) |
| 53 | + | |
| 54 | ArtificialHB.Name = 'Heartbeat' | |
| 55 | script:WaitForChild('Heartbeat')
| |
| 56 | ||
| 57 | frame = 1 / 60 | |
| 58 | tf = 0 | |
| 59 | allowframeloss = false | |
| 60 | tossremainder = false | |
| 61 | lastframe = tick() | |
| 62 | script.Heartbeat:Fire() | |
| 63 | ||
| 64 | game:GetService('RunService').Heartbeat:connect(function(s, p)
| |
| 65 | tf = tf + s | |
| 66 | if tf >= frame then | |
| 67 | if allowframeloss then | |
| 68 | script.Heartbeat:Fire() | |
| 69 | lastframe = tick() | |
| 70 | else | |
| 71 | for i = 1, math.floor(tf / frame) do | |
| 72 | script.Heartbeat:Fire() | |
| 73 | end | |
| 74 | lastframe = tick() | |
| 75 | end | |
| 76 | if tossremainder then | |
| 77 | tf = 0 | |
| 78 | else | |
| 79 | tf = tf - frame * math.floor(tf / frame) | |
| 80 | end | |
| 81 | end | |
| 82 | end) | |
| 83 | ||
| 84 | function swait(t) | |
| 85 | if t == 0 or t == nil then | |
| 86 | script.Heartbeat.Event:Wait() | |
| 87 | else | |
| 88 | for i = 0, t do | |
| 89 | script.Heartbeat.Event:Wait() | |
| 90 | end | |
| 91 | end | |
| 92 | end | |
| 93 | ||
| 94 | function sound(id, parent, vol, pitch, timepos) | |
| 95 | local s = Instance.new('Sound')
| |
| 96 | s.Parent = parent | |
| 97 | s.SoundId = id | |
| 98 | s.Volume = vol | |
| 99 | s.PlaybackSpeed = pitch | |
| 100 | s.TimePosition = timepos | |
| 101 | s:Play() | |
| 102 | game.Debris:AddItem(s, s.PlaybackSpeed + 5) | |
| 103 | end | |
| 104 | ||
| 105 | function camshake(duration, intensity) | |
| 106 | coroutine.wrap(function() | |
| 107 | for i = 0, duration*60 do | |
| 108 | hum.CameraOffset = v3(rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10),(intensity*10))/10, rand(-(intensity*10), (intensity*10))/10) | |
| 109 | swait() | |
| 110 | end | |
| 111 | hum.CameraOffset = v3(0, 0, 0) | |
| 112 | end)() | |
| 113 | end | |
| 114 | ||
| 115 | function readyrewind() | |
| 116 | cantimerewind = false | |
| 117 | cooldown = true | |
| 118 | onrewind:Play() | |
| 119 | for i,v in pairs(workspace:GetDescendants()) do | |
| 120 | if v:IsA('BasePart') then
| |
| 121 | local lastpos = v.CFrame | |
| 122 | table.insert(past, {part = v, change = lastpos})
| |
| 123 | end | |
| 124 | if v.Parent then | |
| 125 | local lastparent2 = v.Parent | |
| 126 | table.insert(lastpast, {part2 = v, change4 = lastparent2})
| |
| 127 | end | |
| 128 | if v:IsA('Camera') then
| |
| 129 | local lastcam = v.CFrame | |
| 130 | table.insert(past, {cam = v, change3 = lastcam})
| |
| 131 | end | |
| 132 | if v:IsA('Sound') then
| |
| 133 | if v ~= rewind then | |
| 134 | local lastsongpos = v.TimePosition | |
| 135 | table.insert(past, {sound = v, pchange = lastsongpos})
| |
| 136 | end | |
| 137 | end | |
| 138 | if v:IsA('Humanoid') then
| |
| 139 | local lasthp = v.Health | |
| 140 | local always = lasthp | |
| 141 | table.insert(past, {health = v, hchange = lasthp})
| |
| 142 | end | |
| 143 | end | |
| 144 | newpast = workspace.DescendantAdded:Connect(function(v) | |
| 145 | if v:IsA('BasePart') then
| |
| 146 | local lastpos = v.CFrame | |
| 147 | local lastparent = v.Parent | |
| 148 | table.insert(past, {part = v, change = lastpos, change4 = lastparent})
| |
| 149 | end | |
| 150 | if v.Parent then | |
| 151 | local lastparent2 = v.Parent | |
| 152 | table.insert(lastpast, {part2 = v, change4 = lastparent2})
| |
| 153 | end | |
| 154 | if v:IsA('Camera') then
| |
| 155 | local lastcampos = v.CFrame | |
| 156 | table.insert(past, {cam = v, change3 = lastcampos})
| |
| 157 | end | |
| 158 | if v:IsA('Sound') then
| |
| 159 | if v ~= rewind then | |
| 160 | local lastsongpos = v.TimePosition | |
| 161 | table.insert(past, {sound = v, pchange = lastsongpos})
| |
| 162 | end | |
| 163 | end | |
| 164 | if v:IsA('Humanoid') then
| |
| 165 | local lasthp = v.Health | |
| 166 | local always = lasthp | |
| 167 | table.insert(past, {health = v, hchange = lasthp})
| |
| 168 | end | |
| 169 | end) | |
| 170 | end | |
| 171 | ||
| 172 | function timerewind() | |
| 173 | if cooldown then | |
| 174 | rewind:Play() | |
| 175 | sine = 0 | |
| 176 | onrewind:Stop() | |
| 177 | coroutine.wrap(function() | |
| 178 | local cce = Instance.new('ColorCorrectionEffect', game.Lighting)
| |
| 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 | cce.TintColor = cce.TintColor:lerp(Color3.fromRGB(255, 0, 0), 0.050) | |
| 228 | effect2.Transparency = effect2.Transparency + 0.020 | |
| 229 | effect3.Transparency = effect3.Transparency + 0.020 | |
| 230 | effect2.Size = effect2.Size:lerp(v3(0, 0, 0), 0.050) | |
| 231 | effect3.Size = effect3.Size:lerp(v3(0, 0, 0), 0.030) | |
| 232 | if effect2.Transparency >= 1 then | |
| 233 | effect2:Destroy() | |
| 234 | end | |
| 235 | if effect3.Transparency >= 1 then | |
| 236 | effect3:Destroy() | |
| 237 | end | |
| 238 | swait() | |
| 239 | end | |
| 240 | end)() | |
| 241 | wait(1) | |
| 242 | blur:Destroy() | |
| 243 | cce:Destroy() | |
| 244 | end)() | |
| 245 | wait(1.5) -- cooldown | |
| 246 | past = {}
| |
| 247 | cooldown = false | |
| 248 | end | |
| 249 | end | |
| 250 | ||
| 251 | mouse.KeyDown:connect(function(key) | |
| 252 | if str.lower(key) == 'r' and cantimerewind and cooldown == false then | |
| 253 | readyrewind() | |
| 254 | elseif str.lower(key) == 'r' and cantimerewind == false and cooldown then | |
| 255 | timerewind() | |
| 256 | end | |
| 257 | end) | |
| 258 | ||
| 259 | hum.HealthChanged:connect(function() | |
| 260 | if selfrewind then | |
| 261 | cooldown = true | |
| 262 | cantimerewind = false | |
| 263 | timerewind() | |
| 264 | end | |
| 265 | end) |