Say I had OrderedDataStore A, in this code:
local A = game:GetService("DataStoreService"):GetOrderedDataStore("Group Troopers") --Creates my new DataStore
game.Players.PlayerAdded:connect(function (Player)
if not A:GetAsync(Player.Name) then
A:SetAsync(Player.Name, [CURRENT TOP NUMBER + 1])
end
end)
(Assume that I went in the console and made a placeholder with value 0, so that would be the greatest number in the store.)
Where I have [CURRENT TOP NUMBER + 1], I want to script it so that the script will search through the datastore for the HIGHEST NUMBER, then add 1 to it for the new trooper number. How can I go about this?
Thanks in advance, SquirrelOnToast

2 comments
Look up "GetOrderedAsync" <- It loads data even if people arnt in the server ;D
So I could just set the ids per page to 1, and make a function go through the table checking if it's the end page? Sounds good