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

Error keeps appearing that Health is a numbervalue ???

Asked by 5 years ago

Ok so this serverscript is in serverscriptservice and when i play it, it keeps showing me this error saying that 18:58:50.980 - ServerScriptService.Script:18: attempt to index field 'Health' (a number value)

heres my script

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)


         BillBoardGui = game.Workspace:WaitForChild(player.Name).Head:WaitForChild('BillboardGui')

        local ServerStorage = game:GetService("ServerStorage")



        local Red = BillBoardGui.REDNess

        local Green = Red.GreenESS


        local Hum = char.Humanoid

            Hum.Health.HealthChanged:Connect(function(HealthChanged)

                            Red:TweenSize(UDim2.new(HealthChanged/Hum.MaxHealth,0,1,0))


            end)
    end)
end)

1 answer

Log in to vote
1
Answered by 5 years ago

HealthChanged is an event of humanoid.

So just do Hum.HealthChanged instead of Hum.Health.HealthChanged

0
Also, if the answer is correct. Don't forget to accept his answer, it really helps answerers a lot! mixgingengerina10 223 — 5y
Ad

Answer this question