How do I make a system where players can go through walls but not the floor?

Hello! How do I make a system where players can go through walls but not the floor?

2 Likes

So you would just make the walls cancollide = false when you want players to be able to walk through walls.

Here is a noclip script that works perfectly. Make sure it is in starter character scripts and that it is put in a localscript.

wait(0.1)
local Noclipping = nil
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local function NoclipLoop()
	if Clip == false and player.Character ~= nil then
		for _, child in pairs(player.Character:GetDescendants()) do
			if child:IsA("BasePart") and child.CanCollide == true then
				child.CanCollide = false
			end
		end
	end
end
Noclipping = RunService.Stepped:Connect(NoclipLoop)

Won’t that just make the character be cancollide false forever? And he can still fall through floors?

No, if you so desire you can just make it disabled by ending the loop. Also it works perfectly.

Wouldn’t that hurt performance?

Right… Yet you didn’t tell how to turn it off. In an instant, the player would just fall through the floor, unless i am mistaken.

Nope. I intend you to run the code yourself, not to mention that OP is literally asking the work to be done for them. If you so as please to make something that will disable it, just make a button that will literally disable the script.

game.Players.LocalPlayer.PlayerGui:FindFirstChild(“noclip”).enabled = false

Depending on the “system” you have in mind you can use “PhysicsService” and Collision Groups if you’re looking for something more than setting parts cancollide.

2 Likes

Okay, but still, if it is enabled, you will go through walls, but you will also fall through the floor.

You are completely wrong. test the script for yourself.

If you had tested it out you would’ve realized the only way out is to destroy it and reclone it as needed.

Okay, but i still think that it would be better to just have the walls be cancollide false when needed.

all of the collision is handled on the local side. there is literally no need.

Like @3DReality said, it would probably be best to use PhysicsService to handle collisions using CollisionGroups.

1 Like

I think it really depends on what they are trying to accomplish would depend on how they approach the noclip. Your solution was kind of interesting to look into. However I am unsure why you are running a constant loop.

local script -

local player = game.Players.LocalPlayer
local function NoclipLoop()
	 repeat task.wait() until player.Character ~= nil 
		for _, child in pairs(player.Character:GetDescendants()) do
			if child:IsA("BasePart") and child.CanCollide == true then
				child.CanCollide = false
			end
		end
	end
NoclipLoop()

Well one, becuase I just did. I repurposed it from one of my old admin systems becaue I don’t feel like writing new code for someone asking for code.

just use collision group and ur good to go

1 Like

Can’t you just set the walls Collision = false while the floor stays true?

Just make every part in the player CanCollide = false.
It won’t fall as there’s HipHeight preventing it.
(Did you know that character’s legs are already CanCollide false?)