Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game:GetService("StarterGui"):SetCore("SendNotification",{
- Title = "Script pour reculer",
- Text = "Script a été executer",
- Icon = "rbxassetid://11823384169",
- Duration = 15
- })
- local key = "T" --La clé pour initier le flashback sais T
- local flashbacklength = 10 --La durée de stockage du flashback en secondes approximatives
- local flashbackspeed = 1 --combien d'images doivent être sautées pendant le flashback (0 pour désactiver)
- local name = game:GetService("RbxAnalyticsService"):GetSessionId() --identifiant unique au quel les jeux ne peuvent accéder mais qui ne change pas lors des exécutions ultérieures (utilisé pour le nom de la fonction liée)
- local frames,uis,LP,RS = {},game:GetService("UserInputService"),game:GetService("Players").LocalPlayer,game:GetService("RunService") --set some vars
- pcall(RS.UnbindFromRenderStep,RS,name) --unbind the function if previously binded
- local function getchar()
- return LP.Character or LP.CharacterAdded:Wait()
- end
- function gethrp(c) --gethrp extrait de mon script env et dépourvu d'arguments
- return c:FindFirstChild("HumanoidRootPart") or c.RootPart or c.PrimaryPart or c:FindFirstChild("Torso") or c:FindFirstChild("UpperTorso") or c:FindFirstChildWhichIsA("BasePart")
- end
- local flashback = {lastinput=false,canrevert=true}
- function flashback:Advance(char,hrp,hum,allowinput)
- if #frames>flashbacklength*60 then --ms'assurer que nous n'avons pas trop d'histoire
- table.remove(frames,1)
- end
- if allowinput and not self.canrevert then
- self.canrevert = true
- end
- if self.lastinput then --s'assurer que le stand de la plateforme revient à la normale
- hum.PlatformStand = false
- self.lastinput = false
- end
- table.insert(frames,{
- hrp.CFrame,
- hrp.Velocity,
- hum:GetState(),
- hum.PlatformStand,
- char:FindFirstChildOfClass("Tool")
- })
- end
- function flashback:Revert(char,hrp,hum)
- local num = #frames
- if num==0 or not self.canrevert then --ajouter à l'historique et retourner si aucun historique n'est présent
- self.canrevert = false
- self:Advance(char,hrp,hum)
- return
- end
- for i=1,flashbackspeed do --trames ip (si activé)
- table.remove(frames,num)
- num=num-1
- end
- self.lastinput = true
- local lastframe = frames[num]
- table.remove(frames,num)
- hrp.CFrame = lastframe[1]
- hrp.Velocity = -lastframe[2]
- hum:ChangeState(lastframe[3])
- hum.PlatformStand = lastframe[4] --ip frames (si activé) latformstand pour que le vol redevienne normal
- local currenttool = char:FindFirstChildOfClass("Tool")
- if lastframe[5] then --équiper/déséquiper les outils
- if not currenttool then
- hum:EquipTool(lastframe[5])
- end
- else
- hum:UnequipTools()
- end
- end
- local function step() --fonction qui s'exécute à chaque image
- local char = getchar()
- local hrp = gethrp(char)
- local hum = char:FindFirstChildWhichIsA("Humanoid")
- if uis:IsKeyDown(Enum.KeyCode[key]) then --début du retour en arrière
- flashback:Revert(char,hrp,hum)
- else
- flashback:Advance(char,hrp,hum,true)
- end
- end
- RS:BindToRenderStep(name,1,step) --finalement, lier notre fonction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement