Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Creating a live server list?

Asked by 6 years ago

I'm trying to send info of a server so that other servers can access it themselves easily, and this function is what I have come up with (it works).

I'm worried that it would break or corrupt itself with too many servers, so is there a better way to implement it?

    local topplacestore=datastoreservice:GetDataStore('topplaceids')
    local function settopvalue(value)
        value=value or #game.Players:GetPlayers()
        if not game:GetService'RunService':IsStudio() and canupload.Value==true then
            canupload.Value=false
            local broadcastable=list.ServerSettings['Is Broadcasted'].Value
            if (value==0 and everbroadcasted) or broadcastable then 
                local placedata=topplacestore:GetAsync('global')
                if not placedata or type(placedata)~='table' then
                    return
                end
                local placedataindex=get.idindex(placedata,game.PlaceId)
                if placedataindex==0 then placedataindex=#placedata+1 end
                local placedatavalue=placedata[placedataindex]
                if not(value==0 and placedatavalue==nil) and value~=placedatavalue th
                    if value==0 then-- if 0 remove the stuff
                        table.remove(placedata,placedataindex)
                    else-- if not 0 then broadcast the stuff
                        placedata[placedataindex]=tostring(tostring(game.PlaceId))
                    end
                    everbroadcasted=true
                    topplacestore:SetAsync('global',placedata)
                end
            end
            wait(10)
            canupload.Value=true
        else
        end
    end

Answer this question