Touched/TouchEnded Bug

I was using the sword tool, but when I use an auto clicker in the safe zone, the equip action glitches and says ‘Danger Zone’. I need a fix for this touch issue.
Video in

What is part


inside script

wait(2)

script.Parent.Touched:Connect(function(part)
	local character = part.Parent
	local humanoid = character:FindFirstChild("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(character)
		if player then
			local safe = player:FindFirstChild("Safe")
			if safe then
				safe.Value = true
			end
		end
	end
end)

script.Parent.TouchEnded:Connect(function(part)
	local character = part.Parent
	local humanoid = character:FindFirstChild("Humanoid")
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(character)
		if player then
			local safe = player:FindFirstChild("Safe")
			if safe then
				safe.Value = false
			end
		end
	end
end)

i hope anyone helping!

I think it’s because Touch and TouchEnded might fire multiple times when a part is moving inside another part. I think those two events were meant for collision or touching of part surfaces, not the inside of a part.

I recommend you use ZonePlus instead.

If not, you can use Workspace:GetPartsInPart() or Workspace:GetPartBoundsInBox() to detect if the player entered or left the zone.