SHOW:
|
|
- or go back to the newest paste.
| 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)
|
| 180 | + | |
| 181 | local effect2 = Instance.new('Part', effects)
| |
| 182 | local effect3 = Instance.new('Part', effects)
| |
| 183 | effect3.Shape = 'Ball' | |
| 184 | effect3.Material = 'ForceField' | |
| 185 | effect3.Anchored = true | |
| 186 | effect3.CanCollide = false | |
| 187 | effect3.Name = 'eff3' | |
| 188 | effect3.BrickColor = BrickColor.new('Really red')
| |
| 189 | effect3.Size = v3(30, 30, 30) | |
| 190 | effect3.Transparency = 0 | |
| 191 | effect2.CastShadow = false | |
| 192 | effect2.Shape = 'Ball' | |
| 193 | effect2.BrickColor = BrickColor.new('Bright red')
| |
| 194 | effect2.Material = 'ForceField' | |
| 195 | effect2.Name = 'eff2' | |
| 196 | effect2.Anchored = true | |
| 197 | effect2.CanCollide = false | |
| 198 | effect2.Size = v3(50, 50, 50) | |
| 199 | effect2.Transparency = 0 | |
| 200 | cantimerewind = true | |
| 201 | for i,v in pairs(past) do | |
| 202 | pcall(function() | |
| 203 | v.part.CFrame = v.change | |
| 204 | end) | |
| 205 | pcall(function() | |
| 206 | v.cam.CFrame = v.change3 | |
| 207 | end) | |
| 208 | pcall(function() | |
| 209 | v.sound.TimePosition = v.pchange | |
| 210 | end) | |
| 211 | pcall(function() | |
| 212 | v.health.Health = v.hchange | |
| 213 | end) | |
| 214 | end | |
| 215 | for i,v in pairs(lastpast) do | |
| 216 | pcall(function() | |
| 217 | v.part2.Parent = v.change4 | |
| 218 | end) | |
| 219 | end | |
| 220 | pcall(function() | |
| 221 | newpast:Disconnect() | |
| 222 | end) | |
| 223 | coroutine.wrap(function() | |
| 224 | for i = 1, 1000 do | |
| 225 | effect2.CFrame = ts.CFrame | |
| 226 | effect3.CFrame = ts.CFrame | |
| 227 | blur.Size = v3(blur.Size, 0, 0):lerp(v3(0, 0, 0), .010).X | |
| 228 | effect2.Transparency = effect2.Transparency + 0.020 | |
| 229 | - | cce.TintColor = cce.TintColor:lerp(Color3.fromRGB(255, 0, 0), 0.050) |
| 229 | + | |
| 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 | end)() | |
| 244 | wait(1.5) -- cooldown | |
| 245 | - | cce:Destroy() |
| 245 | + | |
| 246 | cooldown = false | |
| 247 | end | |
| 248 | end | |
| 249 | ||
| 250 | mouse.KeyDown:connect(function(key) | |
| 251 | if str.lower(key) == 'r' and cantimerewind and cooldown == false then | |
| 252 | readyrewind() | |
| 253 | elseif str.lower(key) == 'r' and cantimerewind == false and cooldown then | |
| 254 | timerewind() | |
| 255 | end | |
| 256 | end) |