hello, I have just started coding on roblox and i want to make a simple clicker/simulator game. why does this code not work for a leaderboard?
game.Players.PlayersAdded:Connect(function(player) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = player
local power = Instance.new("IntValue") power.Name = "Power" power.Value = 0 power.Parent = stats local cash = Instance.new("IntValue") cash.Name = "Power" cash.Value = 0 cash.Parent = stats
game.Players.PlayerAdded:Connect(function(Player) local Leaderstats = Instance.new("IntValue") Leaderstats.Name = "leaderstats" Leaderstats.Parent = Player local Power = Instance.new("IntValue") Power.Name = "Power" Power.Parent = Leaderstats Power.Value = 0 end)
-- Note: It should be a server script, not a local script. There is no reason why this wouldn't work tho. If you want it to save you'll need to add a dataStore.
For more help refer to this page. https://developer.roblox.com/en-us/articles/Leaderboards