Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have done everything right in a script, but its not working?

Asked by 4 years ago

Here is the script:

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

Once I play the game, no errors occur in the output, but it does not kill the player! I think it has something to do with 'FindFirstChild'.

0
Is it in a LocalScript or a ServerScript? Memotag 226 — 4y
0
ServerScript supercatsauthor 22 — 4y
0
Is the script inside the Part? SirGamezy 186 — 4y
0
yes supercatsauthor 22 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Sorry everyone, I answered the question myself. Previously, I had inserted a script into StarterCharacterScripts. The following code was inside:

script.Parent.Health:Destroy()

I wanted the player's health to not regenerate, so I decided to delete the health script. But, what I did not know was that the health script also managed when the player's health is deducted. So i deleted my script, and the problem was fixed!

Ad

Answer this question