Safe Alternative to Remote Functions

I’m making a client-sided hitbox that returns a table of all hit targets. I thought the best way to do this would be with remote functions but I’ve seen a lot about how unsafe and game-breaking Remote functions can be. So I’m wondering what is a safe alternative or a safe way to set up a remote function?

1 Like

Hmmm. I would use IntValues or StringValues in ServerStorage if you want to use remote functions only for server sided scripts. I dont know for local scripts alternatives

By safe I mean preventing the infinite yielding of the remote. I have sanity checks on the server for the “security” of the hitbox

RemoteFunctions aren’t blanket unsafe and gamebreaking. If you’ve seen this, most likely the main problem being highlighted is RemoteFunctions with the intent of a server → client → server flow (server invokes client and client provides a response to the invocation).

SCS flow is unsafe and gamebreaking because the server would be dependent on a response from the client after invocation. A client could change the function for OnClientInvoke so that it never returns which could in turn cause the server to permanently hang expecting a response back.

You can use RemoteEvents to simulate RemoteFunctions while removing the need for the server to depend on a response from the client. You’d be responsible for handling the server → client → server traffic yourself but you’d also get more control such as timing out if you don’t receive a response or developing a better flow for your system.

Remotes are really the only way to achieve the replication you’re looking for (client → server), so rather than looking for alternatives you should be thinking in terms of how to set up your system.

3 Likes