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

How to check if an object is touching a certain part?

I'm trying to make a lift, and I wanted to make a code that checks if the floor of the lift is touching the other end of the lift. I tried to use Touched event but I have no idea of how it works, I also thought about using Region3 but I have the same issue with it.

1 comment

0

Try using the built-in "GetTouchingParts" function for objects

1 answer

✓ Accepted answer

The touched event is what you want to do. In scripts you can check the name of the thing it hit. So if your end of the elevator part has a certain name. It can check if it touched that. Here a script.

script.Parent.Touched:Connect(function(hit) --the (hit) is what it hit.
	
	if hit.Name == "Put the part name here" then --this is what checks if its the elevator part.
		
		
		--Put what you want right here.
		
		
	end	--end's are finishing the script. you need them in all scripts, because I fired 2 events I get 2 ends
end)

--Thats all :D

2 comments

0

Works like a charm, thanks!

0

np

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