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
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
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.