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

how to detect if a play has stopped standing on a block?

so I'm aware of using

script.Parent.Touched:Connect(function()
	--weird function things
end)

but I want to know how to detect is the player stops touching the block, sorta like using a pressure plate or leaving and exiting a certain area

2 answers

✓ Accepted answer

you can use touchended:

script.Parent.Touched:Connect(function(hit)
	print(hit.Name .. " is touching")
end)


script.Parent.TouchEnded:Connect(function(hit)
	print(hit.Name .. " stopped touching")
end)

As a disclaimer, TouchEnded is a bit finiky for some things. Depending on what you're trying to do you might be better off withpart:GetTouchingParts() or Region3

Referred from https://developer.roblox.com/en-us/api-reference/class/BasePart, you can use an event called TouchedEnded

Example. --[[

Sample

In the explorer its

> game
 > workspace
  > Part
   > script

--]]

local a = true; script.Parent.TouchEnded:Connect(function(p) if a then a=false;

	print( p.Name ) -- prints part that untouched script.Parent
	
	wait(1)
	
	a=true;
end

end);

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