I’m quite newbie in these kind of stuff, so please tell me
How will i make clientscripts interact with serverscripts (remoteevents) but then interact with the clientscript again?
2 remoteevents would be too much work. I’m wondering, is there other ways?
So basically i’m making:
The player presses the button
The client interacts with the server, checking if the cooldown is right and that the button was actually pressed
If it’s true, the server would tell the clientscript to play the animation (The server handles the damage)
As you know playing animations on serverside is very laggy. So im doing this to smoothen it a bit.
So if there’s a way, please tell me how
It sends a message to the server with the parameter specified, and the server can respond with whatever value you want. (In this case a boolean)
Example usage:
-- Server
local remote
-- Yes, OnServerInvoke is a property you must set
remote.OnServerInvoke = function(player, x, y, z)
-- WARNING: No yielding allowed! For that use two RemoteEvents
return (x + y) == z
end
-- Client
local remote
-- This will yield until the server responds back
print(remote:InvokeServer(1, 2, 3)) -- true
print(remote:InvokeServer(2, 2, 3)) -- false
Beware that Server → Client → Server interactions (Not your case, you don’t need to worry about it now. Just keep it in mind for the future) can be exploited and the function can be left hanging forever. But, there are ways around this.