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

How to Know When a Player is In Contact with a Part/Union?

1 answer

✓ Accepted answer

To fire when someone makes contact with a part, we would use the inbuilt "Touched" event. You can connect that with the lines below:

script.Parent.Touched:Connect(function()
	-- I always recommend testing if it was a player, I do that like so:
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum then
		-- do something
	end
end)

The script would have to be parented to the part that you want to connect the touched event to for those lines to work. However, you CAN connect it from a different area such as ServerScriptService.

To fire when someone stops touching a part, you can use the inbuilt TouchEnded event. You can connect that one with the same code block, only changing "Touched" to "TouchEnded". Feel free to comment if you have any questions.

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