luaroblox

Message not popping in output after health is 0


I am trying to create some sort of point system in Roblox. I would like it to add 150 points to my score after I kill the Humanoid, but my script isn't doing anything. Any pointers? I am new to this.

Check my code here or just read it below:

local function score(points)
    score = 0
    local points = score + 150
    if game.Workspace.Dummy.Humanoid.Health == 0 then
        print("good")
    end
end

Solution

  • Try using Signal Died (): http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died

    Description: Fired after a character's health reaches 0. Which could be caused either by disconnecting their head from their torso, or directly setting the health property.

    This should provide you an event for when your Humanoid dies.

    Something like this:

    game.Workspace.Dummy.Humanoid.Died:connect(function()
        print("good")
    end)