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

Datastore wont send values through universe in time why?

Asked by
Ortron 27
7 years ago

Tries to figure out how send the stats of the server of a universe game the the main 'hub' of the game to show the playercount of each server except when the last player in the server leaves, it does not send anything to the main hub and stays in the datastore as one player in the server which doesnt exist and cannot be joined.

Here's my script :

local MCTC_Servers=game:GetService("DataStoreService"):GetOrderedDataStore("MCTC_MAIN_3")
local MCTC_Datastore= game:GetService("DataStoreService"):GetDataStore'MCTC_Uptime_MAIN_3'
local Uptime=0

function Send()
    local PlayerCount=game.Players.NumPlayers
    local JobId=game.jobId
    local RawUptime=0
    local RefinedUptime
    local Seconds=Uptime%60
    if string.len(Seconds)==1 then
        RefinedUptime=tostring(math.floor(Uptime/60))..':'..'0'..tostring(Uptime%60)
    else
        RefinedUptime=tostring(math.floor(Uptime/60))..':'..tostring(Uptime%60)
    end
    warn('Sending the following stats')
    warn('JobId - '..JobId)
    warn('Players - '..tostring(PlayerCount))
    warn('Uptime - '..RefinedUptime)
    warn('__________________')
    MCTC_Datastore:SetAsync(tostring(JobId),RefinedUptime)
    MCTC_Servers:SetAsync(tostring(JobId),PlayerCount)
    warn('Stats sent to the Main Hub. (Server - '..tostring(JobId)..')')
end

function QuickSend()
    MCTC_Servers:SetAsync(tostring(game.JobId),game.Players.NumPlayers)
end

game.Players.PlayerAdded:connect(function() Send() end)
game.Players.PlayerRemoving:connect(function() QuickSend() Send()  end) --Desperate attempt at getting it to try and send quicker with the quick send function
while wait(30) do Uptime=Uptime+30 Send() end
0
A data store specific to the universe it was created in. You cannot access another universes data stores. User#5423 17 — 7y
0
that isn't the problem, it sends data to other games in the universe, just not fast enough Ortron 27 — 7y

Answer this question