Help with PlaceVersion

Hello. I want to create a gui that shows if the current server is up to date.
I already have a script that says the placeversion.
How would I go about making a script that would change the text in real time on a server if it’s out of date. It would say SERVER OUTDATED or SERVER UPDATED.

1 Like

PlaceVersion won’t help you for this, I’d recommend checking the actual update time. You can’t really get an immediately real time counter since you’re handicapped by rate limits and all but it would still accomplish the job and let it be about as real time as possible.

Places are still assets so they can be fed to GetProductInfo to return information on the asset. One of your server scripts should hold the content of the Updated field when the server starts up. From there you need to poll GetProductInfo, recommended 5-30 seconds between each fetch. You can then check if the Updated time is different from the one the server first logged. If it is, server’s out of date. You can also stop the polling if the server goes out of date so you aren’t pointlessly polling anymore.

Here’s a guideline you can follow, but I don’t recommend just copying and pasting it because it lacks important features like pcalling GetProductInfo and failure handling.

local MarketplaceService = game:GetService("MarketplaceService")

-- We're effectively using the Updated time as a version identity
local serverVersion = MarketplaceService:GetProductInfo(game.PlaceId).Updated

-- Conditional so we can break off our loop later
local serverOutdated = false

while not serverOutdated do
    local currentUpdate = Marketplace:GetProductInfo(game.PlaceId).Updated
    -- Set serverOutdated variable to the evaluation of "currentUpdate is not
    -- equal to serverVersion" (this statement is either true or false).
    serverOutdated = currentUpdate ~= serverVersion

    -- Keep ample time between each iteration so you don't hit rate limits
    task.wait(15)
end

-- Since no subsequent code runs until a while loop finishes, this is safe
-- to write. We fire a remote telling all clients to update their Gui's text
-- to "server outdated". That, or whatever you'd like.
SomeRemote:FireAllClients()
4 Likes