Kill block not working 100% of the time

I want to make a kill block for an obby

For the kill block I have if you touch it quickly it will not kill you and you can continue the obby without dying and going back to the beginning of the stage

Screenshot 2021-05-22 151139

I tried making it so the script will put the player’s health at -500 instead of 0 but that still did not work

1 Like

Have a debounce in the touch event.

local Debounce = false -- debounce for touch event
local Damage = 25 -- how much damage the humanoid will take
local WaitInbetweenDamge = 1 --how many seconds between each damage

script.Parent.Touched:Connect(function(part) -- reference the part that is touched
	local Player = game.Players:GetPlayerFromCharacter(part)
	if Player then -- if the part is a player's character then
		if Debounce == false then
			Debounce = true
			part.Parent.Humanoid:TakeDamage(Damage)
			wait(WaitInbetweenDamge)
			Debounce = false
		end
		
	end
end)

I found this to be a problem a while ago and I found a great solution

  1. you want the part to not be too small height wise
  2. you want the CanCollide to be false
  3. add a debounce like @Infinite_Visions said

basically you would fall into the part killing you very easily compared to you being able to walk on it

But I don’t think that a debounce can be the solution, @HowToRobloxYT_TV can you show us your code?

it should look like this:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:FindFirstChild("Humanoid").Health = 0
    end
end)
1 Like

exactly a debounce will only stop you from running code multiple times
not really needed

Yes this is what i was meaning it could be util if he needs to don’t instant kill the player

How this code would kill the player? It is just a product purchase script

@NinjaFurfante07 That was the wrong screenshot

did you look at my solution yet?

I working on putting that stuff in rn

Why do you need CanCollide false?

@NinjaFurfante07 here is the right screenshot

Screenshot 2021-05-22 174825

I replied to myself earlier you can check that out

trust me CanCollide set to false helps a lot

btw make “connect” into “Connect”

The c could be the problem? image, try Connect and not connect, do you get any errors in the output?

its not the problem, but it should be changed since connect is deprecated

ok the kill block I was using was a free model and I cant catch errors like that because I dont know how to script and look up a tutorial for every thing

Just add a part and put a script inside with this code:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent:FindFirstChild("Humanoid").Health = 0
    end
end)

its good to look at free models and see how they work
not that big of a deal