Is my cooldown system fine for performance?

Apologies if this is the wrong category, i wasnt sure which one would fit.

Anyways, For my combat game, i have cooldowns (so that players cant spam the weapons lol)

The current system, is so there is a module script in ServerStorage, Lets say i have an explosive projectile, On the server script for the tool, when thrown, Tell the module the player who threw it, the cooldown time, and the tool name, Is this alright? or will it be bad for performance?

My guess is its fine, Since the server script basically just runs the module script’s function, so its as if the server script is doing it all. But, the function uses a task.spawn with 1 tween, which is for the bar of the cooldown, Ive heard that task.spawns can be a little laggy, and that tweens on the server arent the best.

If anyone can tell me if this is alright or not i’d really appreciate it.

3 Likes

i’d suggest maybe looking into this video

3 Likes

I’m not exactly looking for optimizing tweens, i’m more so looking for if i should use the module script on the client (which is definitely better, but how do i tell the client that a cooldown should happen without having to use remote events? unless its fine for almost every weapon to do that.), or if i should just not use a module script all together.

2 Likes

for performance reasons, you might want to consider handling the cooldown logic on the client side.
but, if you’re concerned about security, maybe a hybrid approach could be the move.

the hybrid could be where basic cooldown validation is done on the client side for responsiveness, and more robust validation is performed on the server side to prevent exploits. this way, you balance performance and security.

2 Likes

Im not too bothered about security/the cooldown GUI not matching up 100% with the actual cooldown, The actual cooldown for tools are handled via server.

Basically, My only question is:
How can i tell the client when a cooldown is ready?

I know this isnt impossible, and i can think of a few ways to do it, Such as RemoteEvents, But im not sure if like 30 different tool server scripts telling the player holding the tool a cooldown is ready would be very performant, But, i barely have much knowledge of how to save on performance, so im not sure if this is fine to do, or if its a horrible idea.

1 Like

maybe use collection service?

with collection service, you can handle all of the tool logic from one server script, making it much more performant than 30 server scripts, one per tool.

2 Likes

Every tool is different (unless two players got the same tool)

So therefore, i dont think i could use Collection Service, since every tool is organized differently.

Having all those scripts running isnt my main concern, its the RemoteEvents themselves, Would it be alright for specific tools to tell the client a cooldown is starting?

it might be alright, depending on how many remote events are being ran, and the frequency at which they are being fired.

i wouldn’t worry too much if you’re not absolutely spamming the client with remotes.

2 Likes

Ah, okay.

just a question:
If there were alot of remote events telling the client about a cooldown, would it lag on the server? or on the client?

1 Like

it would degrade performance all around, yes

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.