Module works, but the values affect everyone

the code in this, works as intented. But i want to add a double trouble in the future. when its required for two different players, and say one player uses one of their abilities: for some reason the other player cannot use ANY other abilities until canattack = true.

anyone have any solutions to this?

1 Like

What script are you requiring it from?

a module fires an event to both the client and server. they both have to require it to really make it work properly

You would need to do a player-based debounce. Right now, it’s module-wide using 1 local variable.

So if one player uses a move and the local variable is set to true, it will affect everyone.

You should make a table with the player’s name and their own canattack variable, or the last time they used the ability

for example

local PlayerDebounces = {} -- table for the individual cooldowns

PlayerDebounces[player].canattack = false -- setting it to false
-- replace player with the player variable and so on
2 Likes

That might be a problem.

When you require the module script from a server script it will run it on the server but on a local script it runs it on the client. Shown by the API.

And when you require it from a server then a local script you can specify which code will be used, see the the image above RunService:IsServer() elseif RunService:IsClient()

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