How do I make an anti-noclip script

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.

5 Likes

I think you can do it like this.

  1. On the server log continuously log the position of the humanoid root part (HRP)

  2. Raycast between the current HRP position with the previous HRP position

  3. 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.

Edit:

Whoa in fact it’s the exact same concept as the anti noclip script suggested by @ItsPlasmaRBLX made by @x86_architecture

2 Likes

This post might help you out!

2 Likes

I tried what you sent me a while back and their script is not working at all.

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.

1 Like

It does work for me, did you make sure to insert it into StarterCharacterScripts?

Edit: Yeah here is how it should look like

1 Like

Put what in StarterCharacterScripts? I added the model into my game and it tells me to keep the only script in workspace.

Ok. Nvm, I figured it out. It works almost flawlessly with parts, but it has a false positive which is going through terrain water. How do I fix that?

1 Like

Ok nvm. I found a fix for it. just checked if the material was water. Simple fix :+1:

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.
image
W000: (7,43) Generic Luau error: Type Enum.Material cannot be compared with == because it has no metatable

OK so I fixed it again by using ~= instead of not but apparently its detecting terrain but when I check the material name it says it’s plastic

you can just check if the material isn’t made of the material that is not supposed to be clipped by the player

I’m sorry but did you read anything I said prior? I have three posts right before you explicitly suggesting checking the material doesn’t work.

It detects water as plastic, but still detects it as a material which is weird.

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.

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {Character}
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(Origin, Destination - Origin, raycastParams)

Use the raycastParams.IgnoreWater

1 Like

This is the first thing I said on the OP


The script I’m using uses Ray.new

How do I put raycastparams in there

Use WorldRoot | Documentation - Roblox Creator Hub

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {Character}
raycastParams.IgnoreWater = true
local raycastResult = workspace:Raycast(OldRootPosition, HumanoidRootPart.Position - OldRootPosition, raycastParams)
if raycastResult then
	HumanoidRootPart.CFrame = CFrame.new(OldRootPosition)
end

or try

Hit = workspace:FindPartOnRayWithIgnoreList(Raycast, Character:GetDescendants(), false, true)

2 Likes

Theres a property on FindPartOnRay which ignores water.

workspace:FindPartOnRay(ray,ignoreObject,false,true) 
2 Likes