Turning player collisions off temporarily

Hello, the title says it all. I would like to know how to turn off player collisions temporarily, preferably in a localscript. I need to make the player basically when pressing a gui button have his collisions turn off meaning he can go through a wall. I’m gonna do something where I don’t want to set every walls collisions off. I’ve tried turning it off but it automatically sets it back whether is serversided or not. I’ve heard of physics service, but are you able to turn that off and on with a localscript?

2 Likes

If i remember correctly, some bodyparts cant have their collisions disabled, each time you do it switches back to its original state, so, no i dont think its possible.

You could disable collisions on every other part inside a localscript so it doesnt affect other players.
If you dont want to do it manually you could name every part that the player needs to go through with the same name, and then loop through all the parts, if it has that name, disable collisions.

Well the problem with that is i get the error:
The current identity (2) cannot Class security check (lacking permission 6)

The script:

for i, v in ipairs(game:GetDescendants()) do
    if v.Name == "Seperator" then
        v.CanCollide = false
    end
end

Anything to fix this?

Try looking for the workspace’s descendants instead

1 Like

Ohhh waiit i thought it went through the workspace, sorry my brain is dumb. Ill try that now then mark as solution.

Dont worry, it happens to all of us, hope i was able to help.

2 Likes

Okay, it works now. Thank you!

1 Like