Title. I want to make a tool that, when clicked, increases an exsisting leaderboard through a script (not local). I tried to start one on my own, but It didn't work without using a local script.
For some reason, when I use a LocalScript, the two leaderboards called don't match.
Leaderboard Script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue") --We create a new IntValue
money.Name = "Cash" --this is the name you want the leader-stat to be when it shows up in-game.
money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
money.Parent = leaderstats -- Set the money object as a child of the leaderstats object.
end)
Tool Script:
game.Players.PlayerAdded:Connect(function(player)
local tool = script.Parent
tool.Activated:Connect(function()
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
end)
end)
Thanks in advance!

2 comments
Not an answer but don't use :Connect with a lowercase c
Updated.