#Cooldown problem

1 messages · Page 1 of 1 (latest)

slate ridge
#

What I have is a Skill that player could use by pressing a button (LocalScript) and then it plays an animation, that has an event marker. When animation reaches marker, it sends a signal to a server script that handles the whole skill (movement, damage, etc) and cooldown. That means I can press button and play animations as much as I want and have no cooldown on animation, and there could be solution (FireClient in the server script) and if local script gets this "message" from server script that there is no cooldown, it plays an animation, but there is a problem: If I do it this way, then I should remove event marker and instead delay the skill by myself, until animation reaches the keyframe I want, which is no what I want to have in my script.

What should I do?

devout tendon
#

the cleanest way might be to just let the server decide when the skill can be used, and only then tell the client to play the animation. That way the event marker stays where it is, and the player can’t spam it since the server won’t even send the play signal if it’s on cooldown. Keeps everything synced without having to fake delays or mess with markers.

slate ridge
manic walrus
#

I’d have a debounce that determines whether the skill can be used locally and have your server script return once the cooldown is over which you could determine via os.clock in a task.spawn() loop but you’d have to use remote functions instead

#

That way you can’t spam the animation or even fire the remote again until after your skill fully finishes and the cooldown is over

manic walrus
#

@slate ridge This solution is actually kind of counterproductive considering you're handling unnecessary loop logic on the server when you can just do so on the client

#

once the player fires to the server make the loop logic inside the client script and for the server include a check to see if they can actually use the move taking into account the last usetime with the current time

#

if they fire mutiple times while being on cooldown then its most likely a exploiter firing events so you log or kick them

slate ridge
#

oh, this is actually a good idea

#

I will try it, thank you!