Kill block not working 100% of the time

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

script.Parent.Touched:Connect(function(hit)
    local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") 
    if hit and Humanoid then
        Humanoid.Health = -Humanoid.Health
    end
end)

do this shorter code and make the death block CanCollide false

1 Like

I know its not a problem using free models but I game I made for a past Youtube channel a few people ridiculed me that it was 95% free models in hindsight that was good because now I make 99% of the things in my game instead of only using free models which in my opinion improves the quality of the game

you always gotta start from somewhere

also the main reason I keep saying make the part CanCollide false is because the touched event is too slow and doesn’t detect you hitting the part

which is why it doesn’t kill you instantly

thanks now its killing the player instantly and not waiting like half a second

I don’t think that FindFirstChildWhichIsA("Humanoid") instead of FindFirstChild("Humanoid") could be better even if it works anyways but why you continue to say to set CanCollide false if it isn’t really necessary? You can make a kill part with CanCollide true

Looking at similar issues related to “kill brick delay” this came up:

Is the code you showed us in a “LocalScript” or a “Script”
Also, searching for your specific problem on Google or the DevForum search button would give you plenty of posts related to the problem at hand.

it is better
if something is named humanoid and isn’t a humanoid class it will mess of

meanwhile FFCWIA() will look for the first class that is a humanoid

you could also use FindFirstChildOfClass() instead of FFCWIA()

local debounce = false

script.Parent.Touched:Connect(function(hit)
    local Humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") 
    if hit and Humanoid and debounce == false then
         debounce = true
        Humanoid.Health = -Humanoid.Health
        wait(0.5)
        debounce = false
    end
end)

CanCollide is necessary im serious
it makes a huge difference on if it detects the hit or not

I don’t know why you are not listening

didn’t he say his problem was already fixed :expressionless:

adding a wait will ruin other players if the script is a server script

it will be true but what if I wanted to create a part that kills the player with cancollide true? it is necessary

you can do that

make a CanCollide true part
then make an invisible CanCollide false part that goes taller then then Visible part
make the invisible part the death block

simple problems involve simple solutions

And yes I did say this was fixed @D0RYU solution worked and I marked it as a solution