Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make the .Touched event fire faster?

Asked by 8 years ago

In my game there are tons of trampolines, when I play the game in studio the game works flawlessly and the character bounces where they should go. When I play the game on roblox however, the trampolines have delays when launching and the character does not end up where they should be.

My guess is this is due to lag when the .Touched is fired between the server and the client. How do I speed this up?

Game if you want to test

1 answer

Log in to vote
3
Answered by 8 years ago

You don't

When the Player hits the trampoline, what they're experiencing is lag - The delay over the network between the client making a request, the server responding, and the client interpreting it. In this case, this comes from the fact that the client handles the Character's physics, and therefore the server only knows that the Character touched the trampoline when the client finally tells it, and the client only knows to bounce when the server tells it.

Obviously, this is an issue.
The solution is to make the client handle their own trampolining. This is done through connecting the Touched event in a LocalScript instead of a regular Script. There is however a slight catch, which is of course that LocalScripts don't run when in Workspace. You might want to have a good naming convention or collection of trampolines to solve this one.

Typically, anything requiring immediate feedback after user input should be handled by the client and simply backed by the server - If the server doesn't like it, the server doesn't have to agree. But the client should think that it's happening, so that it happens quickly.

Ad

Answer this question