How do I make an add win to leaderboard script?
So I have a leadeboard script with a number value inside it so it saves:
game.Players.PlayerAdded:connect(function(player)
local DataStore = game:GetService("DataStoreService")
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
for i,v in pairs(script:GetChildren()) do
local d = DataStore:GetDataStore(v.Name)
local x = Instance.new("NumberValue",leader)
x.Name = v.Name
x.Value = d:GetAsync(player.UserId) or v.Value
end
end)
game.Players.PlayerRemoving:Connect(function(player)
for i,v in pairs(script:GetChildren()) do
print("Getting")
local DataStore = game:GetService("DataStoreService")
local d = DataStore:GetDataStore(v.Name)
d:SetAsync(player.UserId, player.leaderstats[v.Name].Value)
print("Saved")
end
end)
I also have an on win function:
return function(winner)
end
end)
My question is, what script do I need inside the win function to give a win to the player? Thanks!

4 comments
Is it an ontouch or an onclick?
no.
I took your script and tested it. The problem was that I couldn't even see the leaderstats in the game. Unless they're supposed to be invisible.
It's because its a saving leaderboard which requires a value