Console Spamming this issue and position dont work
Here script
local datastoreKey = "GlobalCash"
local datastore = game:GetService('DataStoreService'):GetOrderedDataStore(datastoreKey)
local PlayerService = game:GetService("Players")
local remote = game:GetService('ReplicatedStorage'):WaitForChild('Tag')
local currentTopHundred = {}
local function PlayerLoop(player)
coroutine.wrap(function()
local debounce = false
while player and player.Parent and debounce == false do
debounce = true
if not player.Parent then
break
end
local save = player:WaitForChild('leaderstats'):WaitForChild('Cash')
datastore:SetAsync(player.UserId, save.Value)
task.wait(59)
debounce = false
end
end)()
end
local function Clientloop()
coroutine.wrap(function()
while true do
currentTopHundred = {}
local pages = datastore:GetSortedAsync(false, 100)
local topPage = pages:GetCurrentPage()
for i,data in pairs(topPage) do
table.insert(currentTopHundred,{
userID = data.key,
value = data.value
})
end
end
task.wait(60)
end)()
end
Clientloop()
remote:OnServerEvent:Connect(function(player)
for position,data in pairs(currentTopHundred) do
if data[1] == player.UserId then
print(position)
return position
else
continue
end
end
end
game.Players.PlayerAdded:Connect(PlayerLoop())
for _, player in ipairs(game.Players:GetPlayers()) do
PlayerLoop(player)
end