Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
-1

Extra health script won't work?

Asked by 6 years ago
giver = game.Workspace.Fifty+ Health.Head

local player = game.Workspace.LocalPlayer

game.Worksace.player:GetPlayers("Humanoid")

health = 150

function onTouched(giver)
    if players:onTouched(giver) then
        player.Humanoid.Health(health)
    end
 end

script.Parent.Touched:connect(onTouched)

It's when you touch, you get 150 health, it won't work. Why?

0
And here go down votes for no reason... Roboy5857 20 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then   -- if a humanoid exists, then
        humanoid.MaxHealth = 150    -- sets MaxHealth to 150
        humanoid.Health = 150 -- sets Health to 150
    end 
end

script.Parent.Touched:connect(onTouch)

Use this code above. Your code would not work for many reasons. Add the script to your part!

Ad

Answer this question