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

Would it make sense for me to use a touched event in a local script?

Asked by 4 years ago

So what I'm trying to do is make a punch script. To check if what I punched (touched) is a person, I need to use a touched event.

When I click, I could fire my RemoteEvent then use the touched event in the ServerScript that runs when the RemoteEvent is fired.

OR

I can use a touched event in a local script and then fire the RemoteEvent when I punch somebody (so I can do damage).

Which way makes more sense (or more preferable)?

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

In a Script:

If you choose to put it in a script, it will cause more code to run on the server (and for all clients to process), which could in turn cause unnecessary lag if many players are punching at once (though the exact amount of lag is uncalculatable without code). The upside is this would pretty much prevent all exploiting the punch damage and recipient.

In a LocalScript:

If you choose to put it in a LocalScript and fire to a RemoteEvent, this would be the most optimal in terms of game speed and code efficiency. However, you do NOT want to pass any variables other than maybe the arm that is punching to the RemoteEvent from the LocalScript as a clever hacker could easily decompile the LocalScript with exploitation software and make edits to the damage and the recipients (i.e. change the damage caused from 10 to 10000). You would want to put all variables (such as damage and recipient) in the Script in ServerScriptService.

Hope this helped :)

Ad

Answer this question