I have a OrderedData surfacegui, and when displaying the names of the player, it removes the first number from their id. For example, say it's displaying me; it would say "CLONE752", because it removes the first number from my id. I'm not sure why it's doing that, and help is appreciated.
local service = game:GetService("HttpService")
local data = game:GetService("DataStoreService")
local orderedData = data:GetOrderedDataStore("wins")
while wait(60) do
local place = 0
for _, info in pairs(orderedData:GetSortedAsync(false, 5):GetCurrentPage()) do
local plrID = info.key:sub(7)
local data = tostring(info.value)
print(plrID)
place = place + 1
local line = script.Parent:WaitForChild("Frame"):WaitForChild("Line" .. tostring(place))
line.Text = "#" .. tostring(place) .. " | " .. service:GetAsync("http://roproxy.pw/rapi/GetUsernameById/" .. plrID, true) .. " | " .. data
end
end
This is the script that saves the data:
local data = game:GetService("DataStoreService")
local winsData = data:GetOrderedDataStore("wins")
local pointsData = data:GetOrderedDataStore("points")
function UpdateDataStore(player)
if player:FindFirstChild("leaderstats") then
local stats = player.leaderstats
local currentWins = stats:WaitForChild("Wins")
local currentPoints = stats:WaitForChild("Points")
local result = pcall(function()
winsData:SetAsync("users_" .. tonumber(player.userId), currentWins.Value)
pointsData:SetAsync("users_" .. tonumber(player.userId), currentPoints.Value)
end)
if not result then
wait(60)
UpdateDataStore(player)
end
end
end
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
local points = Instance.new("IntValue", stats)
points.Name = "Points"
local wins = Instance.new("IntValue", stats)
wins.Name = "Wins"
local Key = "users_" .. tonumber(player.userId)
pointsData:SetAsync(Key, (pointsData:GetAsync(Key) or 0))
winsData:SetAsync(Key, (winsData:GetAsync(Key) or 0))
points.Value = pointsData:GetAsync(Key)
wins.Value = winsData:GetAsync(Key)
end)

1 comment
It printed "31554827 --- 1554827"