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

"leaderstats is not a valid member of Player (players.maddiesswrld)"?

I don't understand why I am getting this warning, my leaderstats folder is in the player.

game.Players.PlayerAdded:connect(function(player)
	local nextstage = workspace:WaitForChild("Stage"..(player.leaderstats.Stage.Value+1))
	local stage = workspace:WaitForChild(player.leaderstats.Stage.Value)
	wait()
	nextstage.BrickColor = BrickColor.new("Shamrock")		
end)

2 answers

How are you creating the leaderstats folder? If you're creating it through scripts it should be

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
end)

in a Script in ServerScriptService. What this does is creates a folder in the player ever time a player joins.

1 comment

0

Yes I did that in another script. I figured it out a little while ago, thank you though!

You don't need the player's character for this script to work so it should be like this:

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local stage = leaderstats:WaitForChild("Stage")
	local value = stage.Value
	local nextstage = workspace:WaitForChild("Stage"..player.leaderstats.Stage.Value + 1)
	
	wait()
	nextstage.BrickColor = BrickColor.new("Shamrock")
end)

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