I’m trying to recreate tracers rewind ability, where she can rewind her position for the last x seconds (using 3 for now)
right now, i’m using this code:
-- save data, written on phone so might be slightly off
coroutine.wrap(function()
while wait(0.05) do
local count = 1
for i,v in Positions do
if os.clock - v.Time > 3 then
Positions={}
break end
count+=1
end
end
Positions[count] = {
["CameraCFrame"]=Camera.CFrame, ["Player Pos"]=Character. HumanoidRootPart.CFrame ["Time"]=os.clock()
}
end
end)
-- use list
for i = #Pos, 1, -1 do
local index = Pos[i]
end
although this code leads to positions being wiped every 3 seconds (position = {}) and you can sometimes have a really short rewind.
what would be a better way to store players position for the last 3 seconds?