#How should i make serversided cooldown for a combat system?

24 messages · Page 1 of 1 (latest)

eternal ermine
#

Remote events. Global Variables using _G or Using a IntValue/BooleanValue

floral mural
#

So just make a table for every ability?

eternal ermine
#

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.

floral mural
#

Wont this cause memorys leaks , And is there not a better way then writing ability1 , ability 2 in your table

eternal ermine
#

No clue tbh.

#

["ability 2"] = false --I think

#

You could always remove the dictionary when the player leaves using _G[player.id] = nil

floral mural
#

also using wait is subotimal isent it

#

i should use :Time()

eternal ermine
#

I've never used :Time(), so go ahead lmao. 😛

rough coralBOT
#

studio** You are now Level 2! **studio

floral mural
#

i think time was the best cause it used miliseconds

#

so it will be most accrutate

eternal ermine
#

ooo

#

I'll remember that.

floral mural
#

how ever it always prints allowed to attack

#

maybe im just being stupid but ong i do not understand

eternal ermine
#

Print out the variables

#

Debug it.

grim nebula
#

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.