Attempt to nil index with 'humanoid'

I’ve had someone reply for something they said would help then I got an error saying attempt to nil index with ‘Humanoid’

local Humanoid = player.Character:FindFirstChild(‘Humanoid’)
plrs.Character.Humanoid.Died:Connect(function()
if plrs.leaderstats.InGame and not plrs.Winner == true then
plrs.leaderstats.Elo.Value = plrs.leaderstats.Elo.Value - EloDown
table.remove(plrs,x)
print(player.Name…" Is dead")

1 Like

You wrote “plrs.Character.Humanoid”, to me this seems very weird.

I’ll give you some code you could read over and use.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character:WaitForChild("Humanoid").Died:Connect(function()
			print(Player.Name .. " died!")
		end)
	end)
end)
1 Like

If you wants to use the term “plrs” first make it into a variable. For example:

local plrs = player -- change player to whatever you need to reference to find the player

Thought I added to the explanation, but I do have a variable.

Huh. No. Could you please use the “````” when you make code. For example

print("Let's code! :D")

That way it will make it easier for us to see indents and other stuff. Can we please see your code?

Read my solution, it provides working code.

It wants me to delete the else I have But I need the else when I add your code.

the reason its not working its because the humanoid take time to load but you are already executing the script, and scripts execute very very fast so instead, try waiting for the character first then wait for the Humanoid

Use my code and replace your current code with it.
You should add whatever you want to happen when the player dies where print(Player.Name .. " died!") is.

Here I’m testing it I’ll see if there are any more errors.