local plr = game.Players.LocalPlayer
local dispHealth = script.Parent
local numHealth = dispHealth.Parent.healthNumber
local human = workspace:FindFirstChild(plr.Name).Humanoid
dispHealth.Size.X.Offset = human.Health * 2
Error message: Players.scourge495.PlayerGui.ScreenGui.healthBG.healthBar.Script:4: attempt to index a nil value
I am fetching the local Player that this script is attached to in line 1, and then i use it as a reference to try and fetch the player models humanoid.
I have attempted it without the additional '.Humanoid' and it finds the players model just fine. Also I have tried :FindFirstChild("Humanoid") whilst creating a new variable in the process but the same error message occurs when it attempts to extract a humanoid.
I'm a bit new to scripting but not programming, so simple slipups are still probably happening under my nose. If anyone would be as kind to tell me what aspect I'm missing i'd greatly appreciate it. Thanks!

1 comment
You are using .LocalPlayer in a Script. .LocalPlayer can only be called from a LocalScript (which is why workspace:FindFirstChild(plr.Name) returns nil)