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

Make a part collidable with certain parts?

Asked by 9 years ago

How would i be able to make a part collidable with certain parts, but not with others? (Without turning CanCollide to true and false over and over again)

0
This is a very good question that I'd like to know the answer to. Spongocardo 1991 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

You may get mad for this, but that's the way.

You can create a part that is originally collidable, and make ones with certain names stop.

Let's give an example.

local name1="ball"
local name2="duck"
function touch(hit)
if hit.Name~=name1 or name2 then
script.Parent.CanCollide=false
wait(.5)
script.Parent.CanCollide=true
else
ex=Instance.new("Explosion")
ex.Parent=game.Workspace
ex.Position=script.Parent.Position
end
end
Script.Parent.Touched:connect(touch)


This will let any part without the name duck or ball through. If not, BOOM!

Hope this helped!

-ds

Ad

Answer this question