.Touched function not working properly

When a player touches my kill block, they die instantly. However, if they continuously jump on it, they can stay alive for some reason. (My print statement does not work either) Won’t this affect many Kill blocks in obbies? Is there a way to get through this?

(I also saw this happen in bee swarm simulator.)

Edit: When I use this damaging block script

script.Parent.Touched:Connect(function(object)
	local human = object.Parent:FindFirstChild("Humanoid")
	if human then
		repeat
			human.Health -= 3
			wait(0.1)
		until script.Parent.TouchEnded
	end
end)

The player’s health stops decreasing after they stop moving.

1 Like

BasePart.TouchEnded is an event, the way you use it implies it a boolean. What you’ll want to is something like this;

script.Parent.Touched:Connect(function(object)
	local human = object.Parent:FindFirstChild("Humanoid")
	if human then
		local touching = true;
		script.Parent.TouchEnded:Connect(function(hit)
			if hit.Parent == object.Parent then
				touching = false;
			end
		end)

		while touching do
			human.Health -= 3;
			wait(0.1);
		end
	end
end)

Small side-note, TouchEnded can be inconsistent with characters in particular. There’s perhaps a workaround, but I think this will be alright.