Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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.

0
Yes I did that in another script. I figured it out a little while ago, thank you though! maddiesswrld 30 — 3y
Ad
Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago

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)

Answer this question