#How should i make serversided cooldown for a combat system?
24 messages · Page 1 of 1 (latest)
So just make a table for every ability?
Something like that.
--_G[player.id] = {ability1 = false, ability2 = false}
remoteEvent.onServerEvent:Connect(function(plr,ability)
if _G[plr.id][ability] then
_G[plr.id][ability] = true
wait(5)
_G[plr.id][ability] = false
end
end)
Best way I could try to explain it.
Wont this cause memorys leaks , And is there not a better way then writing ability1 , ability 2 in your table
No clue tbh.
["ability 2"] = false --I think
You could always remove the dictionary when the player leaves using _G[player.id] = nil
I've never used :Time(), so go ahead lmao. 😛
** You are now Level 2! **
how ever it always prints allowed to attack
maybe im just being stupid but ong i do not understand
The best way to create a serversided cooldown for a combat system in Roblox Studio is to use the ReplicatedStorage service. You can use ReplicatedStorage to store data that is shared across multiple servers and instances.
You can use the ReplicatedStorage service to store a cooldown timer for each player. This timer can be set to a specific value when a player initiates combat, and then decremented continuously until it reaches zero. When the timer reaches zero, the player can initiate combat again.
You can also use the ReplicatedStorage service to store the state of the combat system. This will allow you to keep track of when a player has initiated combat, and when the combat has ended. This will allow you to ensure that the cooldown timer is reset when a combat ends, and that players cannot initiate combat again until the timer has expired.
Using the ReplicatedStorage service will ensure that all servers and instances have access to the same data, and the cooldown timer will be consistent across all servers.
Not a good idea
Ai generated message