Recently I’ve been thinking about creating joinable servers from UI, meaning that I would like a better way of fetching let’s say, 10 servers by PlaceId
.
The way I am currently using is to save the PlaceId
s in a Datastore
, which then I would load onto a ServerScript
via OrderedDatastore
. But, I need to get random servers each time, so I would have to use AdvanceToNextPageAsync
about 100 times every time the player want’s to reload the servers(this is done so that servers that have a higher PlaceId
and a lower PlaceId
would have a chance to be picked).
If it’s still confusing, here’s an example:
function ServersModule.GetServers() -- Fires every time the player reloads the server list
local Pages = OrderedServer:GetSortedAsync(false, 10)
for i = 0, math.random(0, 100) do
Pages:AdvanceToNextPageAsync() -- Goes to the next page a random amount of times
end
return Pages:GetCurrentPage() -- Return the page
end
As you can see, this is very inefficient, is there a better way to go around this? Is there a function that I don’t know about that can do this kind of thing? I’m fetching the PlaceId
s so I can teleport the players to that specific server.
All help is appreciated,
Thanks!