Hackers and Characters

I have a Server Script that request the character in to ways:

  1. local character = player.Character or player.CharacterAdded:Wait()
  2. player:DistanceFromCharacter(part.Position)

Can either of these lines of code cause a failure in the script if someone has hacked their character?

FYI: The script works great as is. I just don’t understand enough about what clients can hack that will break Server Scripts. Or, if I can improve these two lines to prevent a failure.

1st line is the correct way of getting a character
2nd line is a way to get a distance between player and part

Hackers cant change anything in the server, other than their character. You will still be able to use Player.Character tho.
Only problem is that they can mess up the position of their character and some properties (walk through walls, fly, speedhack), you should use some form of anticheat to prevent that.

FWIU, script executors (although blocked by Byfron now for the most part so little concerns should be made) executes only localscripts. Unless it uses an unsecured RemoteEvent or methods with arguments without checks, those are fine. Server scripts are held on servers, therefore inaccessible.

Other than that, you should have an anti-teleport as they can mess with Pos/Rot, and anti-walkspeed modification anti-cheat.

How can I NOT wait for the character?

..player.CharacterAdded:Wait()

Or, bypass it if the character is not found?

you could just remove the wait
but you should still check if the character is not found so it doesn’t break

local Character = Player.Character
if Character then
  Distance = Player:DistanceFromCharacter(Part.Position)
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.