I have this global leaderboard created with Ordered Data Store that saves data by username that shows how many times they visited, how can I save it by User Id instead?
Here’s my current script for the ordered Data Store:
local Players = game:GetService(“Players”)
local ods = game:GetService(“DataStoreService”):GetOrderedDataStore(“Visits”)
local clickDetector = Instance.new(“ClickDetector”)
clickDetector.Parent = script.Parent
local canClick = truefunction onPlayerAdded(player)
print(player.Name … " has entered the game")ods:IncrementAsync(player.Name, 1)
end–When a player joins, call the onPlayerAdded function
Players.PlayerAdded:connect(onPlayerAdded)–Call onPlayerAdded for each player already in the game
for _,player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end