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.
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:
1 | game.Workspace.part 1. Touched:Connect( function (touchedpart) |
2 | if touchedpart = = game.Workspace.part 2 then |
3 | part 3. CanCollide = false |
4 | end |
5 | 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:
1 | part 3. CanCollide = true |
Hope this helped <3