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

why is my health script saying that the variable is a function? . _ .

Asked by 3 years ago

you read the title; at line 21 it's referencing Health as a function???

local Player = game.Players.LocalPlayer
local Healths = Player.Health

function Change()
    local CurrentHealth = Player.Health.Value

    if CurrentHealth > 0 then
        print(CurrentHealth)
    else

        for i = 1,0,-.01 do
            script.Parent.BackgroundTransparency = i
            wait()

        end
    end
end

script.Parent.TextButton.Activated:Connect(function()
    script.Parent.Visible = false
    Health.Value == 100

end)

Health.Changed:Connect(function()
    if Health.Value == 0 then
        Change()

    end
end)
0
isn’t the variable supposed to be Healths because Health is unknown kkfilms_1 68 — 3y

1 answer

Log in to vote
0
Answered by
Sparks 534 Moderation Voter
3 years ago

"==" indicates an equality comparison. On line 21, this simply evaluates to true/false. You are looking for the assignment operator "=," to set the health to 100. Also, based on your code, "Health.Value" should be replaced with "Healths.Value" since that is the name of the variable you initialized above.

Ad

Answer this question