Player can spam jump to avoid death

Hey Everyone,
So I’m making an obby for my story game, however there is a problem. The player can spam jump to avoid death!
Here is a gif of what i mean: https://gyazo.com/f9236cb5b28b4496db266bcf3b9298bf

Here is my script:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr.Character then
			plr.Character.Humanoid.Health = 0
		end
	end
end)

Thanks for any help! If it’s not clear, I need to make it so that the player can’t spam jump to avoid dying, and that they die instantely.

2 Likes

I don’t think you need that if statement over there and that might be making it take more time to execute. (if plr.Character)

Try this

script.Parent.Touched:Connect(function(hit)
    local plr = game.Players:FindFirstChild(hit.Parent.Name)
    if plr then
        hit.Parent.Humanoid.Health = 0
    end
end)

Spamjump to not die is simply due to the script being slow, if you have multiple killbricks, try making them 1 union and putting the script in the 1 union instead of every brick on it’s own(do check for correct hitboxes though)

I just moved the killbrick up a bit so that it wasn’t the floor.

3 Likes

Changing to R6 can be another solution if you don’t want to scale the kill bricks too much.