Advertisement
MaxproGlitcher

Code du script pour avancer , et reculer

Mar 3rd, 2023 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. game:GetService("StarterGui"):SetCore("SendNotification",{
  2. Title = "Script pour reculer",
  3. Text = "Script a été executer",
  4. Icon = "rbxassetid://11823384169",
  5. Duration = 15
  6. })
  7.  
  8. local key = "T" --La clé pour initier le flashback sais T
  9. local flashbacklength = 10 --La durée de stockage du flashback en secondes approximatives
  10. local flashbackspeed = 1 --combien d'images doivent être sautées pendant le flashback (0 pour désactiver)
  11.  
  12. 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)
  13. local frames,uis,LP,RS = {},game:GetService("UserInputService"),game:GetService("Players").LocalPlayer,game:GetService("RunService") --set some vars
  14.  
  15. pcall(RS.UnbindFromRenderStep,RS,name) --unbind the function if previously binded
  16.  
  17. local function getchar()
  18. return LP.Character or LP.CharacterAdded:Wait()
  19. end
  20.  
  21. function gethrp(c) --gethrp extrait de mon script env et dépourvu d'arguments
  22. return c:FindFirstChild("HumanoidRootPart") or c.RootPart or c.PrimaryPart or c:FindFirstChild("Torso") or c:FindFirstChild("UpperTorso") or c:FindFirstChildWhichIsA("BasePart")
  23. end
  24.  
  25. local flashback = {lastinput=false,canrevert=true}
  26.  
  27. function flashback:Advance(char,hrp,hum,allowinput)
  28.  
  29. if #frames>flashbacklength*60 then --ms'assurer que nous n'avons pas trop d'histoire
  30. table.remove(frames,1)
  31. end
  32.  
  33. if allowinput and not self.canrevert then
  34. self.canrevert = true
  35. end
  36.  
  37. if self.lastinput then --s'assurer que le stand de la plateforme revient à la normale
  38. hum.PlatformStand = false
  39. self.lastinput = false
  40. end
  41.  
  42. table.insert(frames,{
  43. hrp.CFrame,
  44. hrp.Velocity,
  45. hum:GetState(),
  46. hum.PlatformStand,
  47. char:FindFirstChildOfClass("Tool")
  48. })
  49. end
  50.  
  51. function flashback:Revert(char,hrp,hum)
  52. local num = #frames
  53. if num==0 or not self.canrevert then --ajouter à l'historique et retourner si aucun historique n'est présent
  54. self.canrevert = false
  55. self:Advance(char,hrp,hum)
  56. return
  57. end
  58. for i=1,flashbackspeed do --trames ip (si activé)
  59. table.remove(frames,num)
  60. num=num-1
  61. end
  62. self.lastinput = true
  63. local lastframe = frames[num]
  64. table.remove(frames,num)
  65. hrp.CFrame = lastframe[1]
  66. hrp.Velocity = -lastframe[2]
  67. hum:ChangeState(lastframe[3])
  68. hum.PlatformStand = lastframe[4] --ip frames (si activé) latformstand pour que le vol redevienne normal
  69. local currenttool = char:FindFirstChildOfClass("Tool")
  70. if lastframe[5] then --équiper/déséquiper les outils
  71. if not currenttool then
  72. hum:EquipTool(lastframe[5])
  73. end
  74. else
  75. hum:UnequipTools()
  76. end
  77. end
  78.  
  79. local function step() --fonction qui s'exécute à chaque image
  80. local char = getchar()
  81. local hrp = gethrp(char)
  82. local hum = char:FindFirstChildWhichIsA("Humanoid")
  83. if uis:IsKeyDown(Enum.KeyCode[key]) then --début du retour en arrière
  84. flashback:Revert(char,hrp,hum)
  85. else
  86. flashback:Advance(char,hrp,hum,true)
  87. end
  88. end
  89. RS:BindToRenderStep(name,1,step) --finalement, lier notre fonction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement