Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

" leaderstats is not a valid member of Player "Players.Manby7"?

By the way, this is a local script.

local player = game.Players.LocalPlayer

local Plus = player.PlayerGui.PlusMaterialNotification

player.leaderstats.Steel.Changed:Connect(function()

	local tab = Plus:GetChildren()

	local random = math.random(1,#tab)

	local selected = tab[random]
	
	print("e")

	selected.Text = "+5 Steel"
	
	wait(1.3)
	
	selected.Text = ""
	
end)

player.leaderstats.Wood.Changed:Connect(function()

	local tab = Plus:GetChildren()

	local random = math.random(1,#tab)

	local selected = tab[random]
	
	print("e")

	selected.Text = "+5 Wood"

	wait(1.3)

	selected.Text = ""

end)

player.leaderstats.Stone.Changed:Connect(function()

	local tab = Plus:GetChildren()

	local random = math.random(1,#tab)
	
	print("e")

	local selected = tab[random]

	selected.Text = "+5 Stone"

	wait(1.3)

	selected.Text = ""

end)

Whenever I run the script, I get this error: leaderstats is not a valid member of Player "Players.Manby7" Any help would be greatly appreciated!

4 comments

0

Do you have a leaderstats folder in the player or character?

0

Yes, and it is all spelled correctly. i checked more times than i can count lol

0

Are your leaderstats already established on the server? Here you haven't created them yet, only called for a Change signal.

0

Yes, they were already created. Just for clerification I looked inside of the Player. It also showed it on the top right

1 answer

✓ Accepted answer

Try: player:WaitForChild("leaderstats")

The folder may not have loaded.

1 comment

0

This worked. Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.