AutoUpdate - Detect Place Version

How would i detect if the game place version is the latest and if not initiate softshutdown?

1 Like

I think you can check version by getting the product info from marketplace service by passing in the games placeid then checking that against the previous response. This would need to be set up in a while loop

3 Likes

Using game.PlaceVersion in a while loop and caching the previous PlaceVersion so you can compare it to the current one.

2 Likes

it just prints 0 /:
i dont think i am doing this right

1 Like

It will always return 0 in Studio and if you’re calling it in a LocalScript. You must use a normal Script and check the console in a real game.

2 Likes
function getLatestVersion()
	local success, productInfo = pcall(function()
		return game.MarketplaceService:GetProductInfo(game.PlaceId)
	end)

	if success then
		warn(productInfo.Updated)
		return productInfo.Updated
	else
		warn("Failed to retrieve the latest version info.")
		return nil
	end
end




while true do
	wait(2)
	local LatestVersion = getLatestVersion()
	local PlaceVersion = game.PlaceVersion
	if LatestVersion > PlaceVersion then
		warn("place outdated")
	else
		warn("place up tp date")
	end
end

1 Like

.Updated is a timestamp of when the asset was last changed in a string format 2022-02-12T11:22:15Z. You can’t get the PlaceVersion using the MarketplaceService. You should do this:

local PreviousVersion

while task.wait(60) do
	local PlaceVersion = game.PlaceVersion

	if PreviousVersion and PreviousVersion < PlaceVersion then
		warn("place outdated")
	else
		warn("place up tp date")
	end

        PreviousVersion = PlaceVersion
end

okay. i will try this, thank you.

could you eventually help me with my next issue also? its about getting a math random

game.placeversion is the current running server which means it doesnt detect the new version

Try this.

local InsertService = game:GetService("InsertService")

InsertService:GetLatestAssetVersionAsync(game.PlaceId)

im having the same issue, and this code actually prints an long number, which is nowhere near the place version
image
There is people on devforum that figured it out, but you need to use an proxy, and you then authentication to use the roblox api, since httpservice doesn’t allow roblox apis

It returns the latest AssetVersionId of the game. You can still compare it with the previous AssetVersionId to see if it changed aka if the game updated.

i am confuused, is there no way to do this?

local InsertService = game:GetService("InsertService")

local PreviousVersion

while task.wait(60) do
	local CurrentVersion = InsertService:GetLatestAssetVersionAsync(game.PlaceId)

	if PreviousVersion and PreviousVersion ~= CurrentVersion then
		warn("place outdated")
	else
		warn("place up to date")
	end

	PreviousVersion = CurrentVersion
end

AMAZING! It works, you are a genius thanks so much :smiley:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.