My current system is have an event listener in the server script service, create a new event for anything I need to happen on the server from a local script, and write the event code in the listener. To my knowledge this is the best way to do serverside interactions from local scripts. Problem is, I’m early in development and this is already filling up. I’m going to have many tools and weapons with different functions, so most of them cannot use the same event with different parameters and will need a new event per tool. Is there any better way to handle this or am I doing it correctly?
You could create the weapon functions in a ModuleScript on the server and the client would just say that it wants to use the weapon’s ability.
The server would then check which weapon it is and use the ability.
There are several ways to do this, but I’ll give you a simple example. (Don’t copy unless it’s useful, just do it the way you want)
WeaponConfiguration = {
ID = 4,
Setup = {
-- All parameters of this weapon
}
}
RemoteEvent:FireServer(WeaponConfiguration)
You can have all the weapon parameters in a ModuleScript that the client can access. Anyway, there are several ways, I can’t say exactly the best ways because it all depends on the game’s construction.
Are you sure you want to do this? This is incredibly risky for exploits, so make sure when you’re scripting the serverside for RemoteEvents, ensure all parameters are valid and there are measures to prevent anyone from exploiting this.
Also, for tools, I am sure there’s a feature where you can check whether a tool is used with a normal script (serverside) so there wouldn’t be much use of using RemoteEvents or whatnot. Could you specify?