Why my script doesn't detect the player's health?
So, I think the problem is the variable in the script I guess? Cause when I see the output its the problem maybe?
So here's my script:
1 | Hum = script.Parent.Humanoid |
2 | statVal = game.Players.LocalPlayer.Stats |
3 | Hum.Health.Changed:connect( function () |
4 | statVal.Health.Value = Hum.Health |
Output :
17:09:19.219 - Workspace.Player1.HealthDetect:3: attempt to index field 'Health' (a number value)
Note : Script is inside StarterCharacterScript.
Please answer in the answer bar, not comments.
EDIT For FlaminSparrow :
Another problem when I type this code :
1 | Hum = script.Parent.Humanoid |
2 | statVal = game.Players.LocalPlayer.Stats |
3 | Hum.HealthChanged:connect( function () |
4 | statVal.Health.Value = Hum.Health |
Output :
17:32:03.756 - Players.Player1.PlayerGui.ScreenGui.TabFrame.StatFrame.Health.LocalScript:4: attempt to concatenate global 'HealthPercentage' (a userdata value)