Hello, im trying to make a Cookie Clicker like game and everything works already. My only problem is that i wanted to implement a small leaderboard (like the ones that are prebuilt into roblox) to display the person with the most cookies on the server.

The main leaderboard works but i cannt change the leaderboard values...

The cookies for each player are saved in _G.cookies

The game works fine in multiplayer (so only the leaderboard part is broken not the game)



game.Players.PlayerAdded:connect(function(player)

	local StartingMoney = (500)

	-------------------------------------------------------- 

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

	local money = Instance.new("NumberValue")
	money.Name = "Money"
	money.Parent = leaderstats
	money.Value = StartingMoney

	local Level = Instance.new("NumberValue")
	Level.Name = "Level"
	Level.Parent = leaderstats
	Level.Value = 1
end)


while true do
	game.Players.LocalPlayer.leaderstats.Level.Value = _G.cookies
end


Thanks in advance.

3 comments

0

I don't think you defined the value "cookies."

0

_G means a global variable replicated across all scripts

0

Make Part And Put this Script In Part, local function onPlayerJoin(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local coins = Instance.new("IntValue") coins.Name = "Money" coins.Value = 200 coins.Parent = leaderstats end game.Players.PlayerAdded:Connect(onPlayerJoin)