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

How would I detect if a part touches anything that is also a part.?

Asked by 8 years ago

I'm trying to figure this out but I have no idea how to do it.

3 answers

Log in to vote
1
Answered by
k3du53 162
8 years ago
Edited 8 years ago

If you wanted to make sure that the other part is a part, then you would use the IsA() function with a Touched event.

game.Workspace.Part.Touched:connect(function(part) --Touched event
    if part:IsA("Part") then --IsA() function
        --code
    end
end)

Or, if you wanted the touching part to be another type of part, like a MeshPart, or WedgePart, you would check if it is a BasePart.

game.Workspace.Part.Touched:connect(function(part) --Touched event
    if part:IsA("BasePart") then --IsA() function
        --code
    end
end)

Good luck!

If this helps, please be sure to accept my answer as this benefits the both of us.

Ad
Log in to vote
0
Answered by
yyyyyy09 246 Moderation Voter
8 years ago
Edited 8 years ago

http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched

Workspace.Part.Touched:connect(function(otherPart)
    if otherPart.ClassName = "Part" then

    end

end)
Log in to vote
0
Answered by 8 years ago

You would first create the function -- Workspace.Part.Touched:connect(function(otherPart) then you would check if the other part is named what you'd like it to be named, it could be object, or anything---- if otherPart.ClassName = "Example" then after this, you'd insert your code. You could do this with a player, but you'd need to check for the humanoid.

If this helped, make sure to accept answer!

Answer this question