Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

Post what you have tried. This isn't a request site..

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.