You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m trying to make a leader board.
What is the issue? Include screenshots / videos if possible!
The tonumber function isn’t working.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local PlrUsername = game.Players:GetNameFromUserIdAsync(tonumber(Data.key))
If you want the full script then say it bellow and i’ll give it to you.
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local DataStoreService = game:GetService("DataStoreService")
local HolderFrame = game.Workspace.WinsLeaderboard.BoardPart.LeaderBoardGui:WaitForChild("HolderFrame")
local WinsInfo = DataStoreService:GetOrderedDataStore("WinsDataStore")
local function UpdateBoard()
local WinsData = WinsInfo:GetSortedAsync(false,5)
local WinsPage = WinsData:GetCurrentPage()
local Success, ErorrMessage = pcall(function()
for Rank, Data in ipairs(WinsPage) do
local PlrUsername = game.Players:GetNameFromUserIdAsync(tonumber(Data.key))
local Name = PlrUsername
local Wins = Data.Value
local IsOnLeaderboard = false
for i,v in pairs(game.Workspace.WinsLeaderboard.BoardPart.LeaderBoardGui.HolderFrame:GetChildren()) do
if v.Name == "PlayerAddedFrame" and v.PlrName.Text == Name then
IsOnLeaderboard = true
end
end
if Wins and IsOnLeaderboard == false then
local NewLeaderboardFrame = game.ReplicatedStorage.LeaderBoardStuff.WinsLeaderBoardFolder.LeaderBoardFrame:Clone()
NewLeaderboardFrame.PlrName.Text = Name
NewLeaderboardFrame.PlrWins.Text = Wins
NewLeaderboardFrame.PlrRank.Text = "#" .. Rank
NewLeaderboardFrame.Parent = game.Workspace.WinsLeaderboard.BoardPart.LeaderBoardGui.HolderFrame
end
end
end)
if not Success then
warn("Something went wrong while updating the leaderboard. " .. ErorrMessage)
end
end
while true do
for _, Plr in pairs(game.Players:GetPlayers()) do
WinsInfo:SetAsync("Player_" .. Plr.UserId , Plr.leaderstats.Wins.Value)
end
for _, Frame in pairs(HolderFrame:GetChildren()) do
if Frame:IsA("Frame") then
Frame:Destroy()
end
end
wait(10)
UpdateBoard()
print("Updated!")
end