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

Why the Humanoid.Health is not changing on this script?

Asked by 4 years ago

I'm using a script (not a local script since it didn't work very well) to change the Humanoid health when the tool is activated, but for some reason its not working.

The script:

local animations = {"4220380816"}
enabled = true


function onActivated()
    if not enabled  then
        return
    end

    enabled = false
    local Tool = script.Parent
    local Char = Tool.Parent
    local random = animations[math.random(1,#animations)]

    local anim = Instance.new("Animation")
    anim.AnimationId = "http://www.roblox.com/asset/?id="..random

    local track = Char.Humanoid:LoadAnimation(anim)
    track:Play()

    script.Parent.Handle.ActivatedSound:Play()
    wait(3)
    Char.Humanoid.Health = Char.Humanoid.Health + 30
    wait(0.5)
    script.Parent:Destroy()
end

script.Parent.Activated:connect(onActivated)

The animation works very well, but when changing the Humanoid health, nope.

0
Humanoid object should go with localplayer script in the tool... c0nc3rt 61 — 4y
0
Humanoid object should go with localplayer script in the tool... c0nc3rt 61 — 4y
0
Do u mean to test the same code with a LocalScript? TomasgameplayPro 2 — 4y
0
yeah try it seikkatsu 110 — 4y
0
I tried it but i don't get good results, when i activate the tool, i get some health but then it goes to my normal health. TomasgameplayPro 2 — 4y

Answer this question