Hey there! So, lets say i have a pvp system and i want an ability to undo about 60 seconds before the ability was used so example:
Ability used
Player’s health goes back to the health player had 60 seconds ago
Player’s position goes back to player’s position 60 seconds ago
I had an idea where i would store the cframe and health every second in a table but it might be too much for the server and stuff, any way i could improve this or make this work?
store the health in some sort of ‘‘NumberValue’’ , like any other value you would save,
then after 60 seconds, this value will overwrite your actual health or something else
and about the cframe, i don’t think the server will die if you use it, since [Era of Althea]
has an back-in-time ability where they actually saves the cframe, OF Everyone that is around you, and i dind’t noticed any sort of lag
You can just use two tables.
Table with hp and table with CFrame
Update both of them every second if the round time is more than 60 seconds.
Do you want to undo hp and position for one character or for all characters in round?
If you want to undo hp and position for one character then
you can just use two variables hp and cframe and update them every second if the round time is more than 60 seconds.
local function MonitorValue(Time, Object, Value)
local History = {}
local Connection = nil
local Works = pcall(function()
table.insert(History, {
Object[Value],
os.time()
})
Connection = Object:GetPropertyChangedSignal(Value):Connect(function()
table.insert(History, {
Object[Value],
os.time()
})
end)
end)
if not Works then
return
end
task.wait(Time)
if Connection then
Connection:Disconnect()
end
return History
end
-- testing, pls remove
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid", math.huge)
print(MonitorValue(
10,
Humanoid,
"Health"
))
end)
end)