Leaderstats will not show up

Hi! I’m really a noob, but I don’t know why my script isn’t working? (bare in mind I tried to make it myself, and didn’t follow a tutorial other than the one i watched about a week ago.) I’ve tried making the folder a model, and I’m kind of stuck here. I asked my friend as he said it should work. It just won’t show up in game, it even prints Leaderstats Creation Successful and there are no error messages. Any help please?

function onPlayerJoin(Player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local cash = Instance.new("IntValue")
    cash.Name = ("Cash")
    cash.Value = 0
    cash.Parent = leaderstats
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

print ("Leaderstats Creation Successful")

Hello. There is fixed script that will work:

function onPlayerJoin(Player)
    local leaderstats = Instance.new("Folder",Player)
    leaderstats.Name = "leaderstats"

    local cash = Instance.new("IntValue",leaderstats)
    cash.Name = "Cash"
    cash.Value = 0
end

game.Players.PlayerAdded:Connect(function(plr)
onPlayerJoin(plr)
end)
print ("Leaderstats Creation Successful")

I hope it will work!

The player you said there, isn’t the same as this:

This works:

function onPlayerJoin(Player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = Player

    local cash = Instance.new("IntValue")
    cash.Name = ("Cash")
    cash.Value = 0
    cash.Parent = leaderstats
end

game.Players.PlayerAdded:Connect(onPlayerJoin)

print ("Leaderstats Creation Successful")
1 Like

That worked, could you explain what you changed so I know for next time? Thanks!

The way you did had no problems, just a spelling mistake.

so Player and player are different instances?

Hello. No problem.
You was calling function without arguments.
I added new function to fire your function and I called function with arguments!

Yes it is, it is caps sensitive, always check your spelling.

Thanks, will do next time! charrrr

1 Like

Ok, thanks for your help! charrrs

1 Like

Yep, I recommend using the Script Analysis tab to help when scripting, as it’ll indicate any small issues like this to you.