This is my script:
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model", player) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = Money money.Value = 100 end)
I got this from the wiki while trying to learn how to make a LeaderBoard. When I play the game, the it says:
SynphonyKnight 0
Not only do I have 0 (not 100, as I set it to), but it says I have 0 "Value", not Money. I guess the wiki is outdated, so will someone please tell me what's wrong with it.
I can't check the output because when I click Play Solo a message pops up saying "Error Loading Starter Script" and Roblox Studio crashes. The only way I can test is by closing and saving the studio, then clicking play, and since I'm normal playing it doesn't have the output.
Please help!!!
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() -- Always do this in Data Persistence. local leaderstats = Instance.new("IntValue", player) -- I don't know if models work but I use IntValues for this. leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = Money money.Value = money.Value +100 end)
EDIT: Added my leaderboard.
game.Players.PlayerAdded:connect(function(Player) a = Instance.new("IntValue") a.Name = "leaderstats" b = Instance.new("IntValue") b.Name = "Points" a.Parent = Player b.Parent = a Player:WaitForDataReady() if Player:LoadNumber("Points") ~= 0 then Player.leaderstats.Points.Value = Player:LoadNumber("Points") end end)