So I don’t want to have a simple anti noclip script which only checks the humanoid controller status that barely works 90% of the time, and can be easily bypassed by something as simple as using the wall-through glitch. I want to have an actual anti-noclip script that uses raycasting and such and will work every time.
In this video shown below, you can see that it teleports you back to your initial position after you did the glitch, and it just looks like it’s completely robust.
On the server log continuously log the position of the humanoid root part (HRP)
Raycast between the current HRP position with the previous HRP position
If the raycast hits a presumed wall or obstacle then teleport the HRP back to the previous position.
Of course, there are some downsides to this method like if the player is really laggy when walking around a sharp corner in a U-shaped path but I think it encapsulates what you are looking for with the raycasting method.
There might be a lot of other downsides if you are really creative like an exploiter but I think it’s what you are looking for to start with.
Is there anything wrong with relying on the Humanoid State? StrafingNoPhysics is a state you could you use to detect no clipping. But I’m not entirely sure if it’s functional, and am not familiar with it.
However like @dthecoolest mentioned, you can raycast between any objects from that last position to the latest position. You can alternatively do region checks as well. However, do be aware that checks on the server can be off, if player was to have bad ping, or otherwise. I think raycasting is a fair solution here. There are definitely a few factors to account for, so don’t be too strict.
Ok nvm. It turns out doing that it completely broke the noclip script at all.
I added
and not Hit.Material == Enum.Material.Water
to it and it gives a blue line error that seys this.
W000: (7,43) Generic Luau error: Type Enum.Material cannot be compared with == because it has no metatable
A common no-clip script uses Humanoid:ChangeState(), maybe by detecting this change in the client (unsafe, but may prevent people that just copy scripts!), you could detect if the new state is the Noclip (11). Some scripts don’t use this for noclipping but this should prevent a few exploiters.