I am making a localscript that is supposed to make the screen read on death, but when I try to check HealthChanged, it gives me this error.
Players.Uniplier.PlayerGui.Death.Death:3: attempt to index nil with 'FindFirstChild'
Here is my code.
local player = game:GetService("Players").LocalPlayer local char = player:FindFirstChild("Character") char:FindFirstChild("Humanoid").HealthChanged:Connect(function() if char.charactervalues.Grabbed.Value == true then local death = script.Parent.Frame if char.Humanoid.Health <= 1 then death.Transparency = 0 end end end)
I'm not sure if it is this, as I've never tried getting the character this way, but instead of doing player:FindFirstChild("Character"), I would recommend using player.Character or player.CharacterAdded:Wait(). If that isn't the problem then try using char:WaitForChild("Humanoid") because theres a chance that the character model shows up but the humanoid has not been loaded yet.