Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a part collide with another part but not with players?

Asked by
Mycran 7
4 years ago

I have a part which upholds a moving part. Problem is if I turn the collisions on the part, the moving part just falls. Yet, if I turn the collisions on, people can just walk on it and skip the lobby. How do I make it so that players cannot walk on it yet the moving part doesn't fall? Anchoring the moving part means the moving part stays still, so that's not a solution.

0
you could weld the parts together then turn off collision jediplocoon 877 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

you would have to use the PhysicsService.. The service allows you to place Baseparts and models in a collision group, then you could set weather or not parts in a certain collision group can collide with parts in another collision group..

learn more about physics service here

0
I am a script boomer I don't understand what I have to do Mycran 7 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Insert this into workspace

local part1 = workspace.Part1 --example
local part2 = workspace.Part2 --example

function touch(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        part1.CanCollide = false
    else
        part1.CanCollide = true
    end
end

function touch2(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        part2.CanCollide = false
    else
        part2.CanCollide = true
    end
end

part1.Touched:Connect(touch)
part2.Touched:Connect(touch2)
0
It doesn't work for me. I changed the top "Workspace.Partnum" to "Workspace.PartName". Does that work or did I mess up? Mycran 7 — 4y

Answer this question