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

If part1 touch part 2 then.. How do I do it?

Asked by
Techyfied 114
5 years ago
Edited 5 years ago

So, I'm making a game where a bus arrives and make the people able to teleport. Else, they can't reach the teleporter. For this i need a script which can detect if a bus is in the place or not

Suppose, the bus' part1 has touched a part2. (part2 is situated in stopage and part1 is in the bus). If it is touched, then part 3 will become Non-Collidable and players can reach the teleporter and get in the bus. Else, part3 will be collidable and players can't reach the teleporter. I know it's confusing, but it would be helpful if you could help.

0
Post what you have tried. This isn't a request site.. niroqeo 123 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

So you will have to set up a touched event on part1 so that if it is touched, and the part that touched it is part2, then it will make part3 non-collidable.

Assuming all these part's parents are workspace, it would go like this:

game.Workspace.part1.Touched:Connect(function(touchedpart)
    if touchedpart == game.Workspace.part2 then
        part3.CanCollide = false
    end
end

Line 1 is listening for the event that part1 touches another part, and 'touchedpart' is the part that it touches

Line 2 checks if the part it touched is in fact part2

Line 3 makes part3 uncollidable, but only if Line 2 passes

If you would like to set up your own way to make part3 back to collidable, you would use:

part3.CanCollide = true

Hope this helped <3

Ad

Answer this question