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

How to fix a 'is server updated' script?

Asked by 5 years ago

Hello, I have been working on a script that recognises if the server is at the latest possible version. I thought the best way to do this was to create a script that when the new server starts up, it updates a variable to show the latest version.

I made this script to do that (running in ServerScriptService):

local DataStoreService = game:GetService("DataStoreService")
local versionStore = DataStoreService:GetDataStore("versionData")

local function version()
    local suc, err = pcall(function()
        versionStore:SetAsync("xdDxd8734372$$%^|%", game.PlaceVersion)
        game.ReplicatedStorage.MaxVersion.Value = game.PlaceVersion
    end)
    if err then
        version()
    end
end
version()

local function update1()
    local success, currentVersion = pcall(function()
        return versionStore:GetAsync("xdDxd8734372$$%^|%")
    end)
end

local update = function()
    game.ReplicatedStorage.MaxVersion.Value = update1()
end
update = versionStore:OnUpdate("xdDxd8734372$$%^|%", update)

print(game.ReplicatedStorage.MaxVersion.Value)

I went to test the script. However, the: OnUpdate function does not work over servers. Do you know an alternative to this function or a completely different way to do this (eg using Pastebin)?

Any help would be appreciated.

0
You do not need the data store at all use https://developer.roblox.com/api-reference/function/MarketplaceService/GetProductInfo as it includes Updated time stamp. User#5423 17 — 5y
0
This won't work, as the game is not a Marketplace item. Thus it does not use the same functions. Tweakified 117 — 5y

Answer this question