Why wont my Kill Script work?

I made a small fun obby game and i added a KillBrick, I then added a KillScript to it but when i tested it, It didnt work and gave me some errors.


script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.health = 0
    end
end)
1 Like

Can you list those errors? Is it in a localscript? (It needs to be a normal script not a localscript)

is the script serverside?

This text will be hidden

In here, Health should be capitalized

Its hit.Parent.Humanoid.Health=0

The errors are health is not a valid member of Humanoid and no it is in a normal script not a local one

Minor side note, but connect is deprecated, it’s a small change but do consider changing it to Connect

Lua is case-sensitive, so you have to specify the properties you want to change

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

health as the error states, is not a valid member, however Health is

https://developer.roblox.com/en-us/api-reference/property/Humanoid/Health

Humanoid | Roblox Creator Documentation (Not a valid API by lowercasing the “H”)

1 Like

so I’m right, Health must be capitalized.

scritt

Hwalth

capitalize “health” to “Health”

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