I have tried this and it didn't work :C please help me with this
function hit (h)
h.health = 0
end
game.Workspace.Part.Touched:connect(hit)
and the output said "health is not a valid member of part" or something
I have tried this and it didn't work :C please help me with this
function hit (h)
h.health = 0
end
game.Workspace.Part.Touched:connect(hit)
and the output said "health is not a valid member of part" or something
Health is not a member of part, it is a part of Part.Parent.Humanoid
function hit (h)
if h.Parent:findFirstChild("Humanoid") then
if h.Parent.Humanoid.Health ~= 0 then --Kinda a debounce
h.Parent,Humanoid.Health = 0
end
end
end
game.Workspace.Part.Touched:connect(hit)
Health isn't actually a thing in your character, it's the Humanoid.
The thing touching it wouldn't be your character, it would be a part of your character, such as your left leg.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
It is not recommended to Cap lock here, and no problem :P
On line 4, you did h.Parent,Humanoid instead of h.Parent.Humanoid, and you didn't capitalize Health.
:P