Hello! I have a tagging system that makes it such that when 2 characters collide, a local script will receive the touch even before firing it to a main script that handles all the tagging in serverscriptservice (I heard that servers load events faster than an entire character, so I use this system). How would I make a server-sided check to make sure that cheaters cannot fire the event from anywhere?
If I tried to get the server to check the distance between the 2 characters, won’t it be inaccurate since the server has not loaded the characters into the position to check?
(also how do i use raycasts to check ive seen raycast checks everywhere on the devforum but have no idea how to use it )
Please correct me if I’m wrongbut I’m pretty sure that the character model would have to already be loaded onto the server (and pushed off to all the players).
That means that there’s no way another client could tag the loading client before their character has even loaded.
How would the Touched event even fire if the client’s character hasn’t even loaded?
By the way, this is how the Touched event works internally:
By having the Touched event be contained in a server script, ya probably won’t need to worry about this.
Good thing about this, is that the player’s position on the server may not represent the client’s current position but the client has to have been at the server’s current position at some point which makes it pretty accurate (again, correct me if I’m wrong)
Check what specifically? If there’s a part in front of the player? You’d probably do something like this:
-- HRP = HumanoidRootPart
local Cast = workspace:Raycast(HRP.Position, HRP.CFrame.LookVector)
-- if the ray hit something then…
if Cast then
-- get what the ray hit
local Hit = Cast.Instance
-- now you can do other checks
end
…Oh?
Now contradicting what I said, it would still be more accurate on the client; but the client could spoof / manipulate and you’d probably have to do some server checks at the end of the day which in my opinion would make the server more desirable
Yea… but will the server have the correct position for each of the characters? Unless I am wrong about characters loading after events, how would the server know the positions that the client sees?
Edit: Does the character’s position property load in before the physical character itself loads in, making the postion and the event load about the same time and it is only the touched event that is delayed if done on the server? If so then yeah I think this check works
If you are not sure, just use a server-side script to handle the touched events, while the client side only provides visuals, for example, highlights indicating the player is close. That way a delay won’t be disclosed.
Then fire the client back whether they had touched.
I was actually using server-sided scripts originally, but I switched to client for its higher accuracy (excluding exploiters). Guess I’ll use server again :\