local DataStoreService = game:GetService("DataStoreService"):GetDataStore("Test")

local HttpService = game:GetService("HttpService")

local data = {}

local function PushData(player)
    coroutine.wrap(function()
        local key = "user_" .. player.UserId
        local pushed = false
        local tries = 0
        pcall(function()
            while not pushed do
                tries = tries + 1
                if data[player] ~= nil then
                    DataStoreService:SetAsync(key, HttpService:JSONEncode(data[player]))
                    pushed = true
                end
            end
            if pushed then
                return true
            end
            if tries == 5 then
                return false
            end
            wait(3)
        end)
    end)()
end

local function PushDataYield(player)
    local key = "user_" .. player.UserId
    local pushed = false
    local tries = 0
    pcall(function()
        while not pushed do
            tries = tries + 1
            if data[player] ~= nil then
                DataStoreService:SetAsync(key, HttpService:JSONEncode(data[player]))
                pushed = true
                print("PushDataYield(g_gamerules::function): Data push yielded.")
            end
        end
        if pushed then
            return true
        end
        if tries == 5 then
            warn("PushDataYield(g_gamerules::function): Data push failed; max tries exceeded. (Error 406)")
            return false
        end
        wait(3)
        warn("PushDataYield(g_gamerules::function): Data push attempt failed; retrying.. (Error 405)")
    end)
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: