When I am in the zone, the TouchEnded is activated when I move but no part left the zone. Is there any way to fix this?
Maybe it’s your feet seeping into the ground. Try making sure the part tat touches (for both events) the area IS the HumanoidRootPart itself.
-- Example (Ik its not neat, you should not copy & paste this)
part.Touched:Connect(function(obj)
local h = obj.Parent:FindFirstChild("HumanoidRootPart")
if h and h.Health ~= 0 then
if h == obj then
print("Player Enter")
end
end
end)
Edit: oops Made a mistake in my code, supposed to be 'HumanoidRootPart' not 'Humanoid'
1 Like
As the above post suggests you should add a check to verify that “TouchEnded” is firing because a player’s character model is no longer touching the part. In addition to this I would also add a debounce as “TouchEnded” can often regularly fire even if it appears as if you never stopped touching the part.
local part = script.Parent
local players = game:GetService("Players")
local debounce = false
part.TouchEnded:Connect(function(hit)
if debounce then
return
end
local plr = players:GetPlayerFromCharacter(hit.Parent)
if plr then
debounce = true
--do code
task.wait() --add a cooldown to the callback
debounce = false
end
end)