Need help with ui updating with placeverison

Here’s the rundown,

My ui updates the build and version i’m on, it updates the build just fine but it will only update my place verison from 1.0.0 to 1.0.1 and anytime my build updates so should my version but it won’t update past 1.0.1.

Script:

local textLabel = script.Parent

textLabel.Font = Enum.Font.TitilliumWeb
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.TextSize = 50
textLabel.BackgroundTransparency = 1
textLabel.TextTransparency = 0.75

local versionTextLabel = Instance.new("TextLabel")
versionTextLabel.Font = Enum.Font.TitilliumWeb
versionTextLabel.TextColor3 = Color3.new(1, 1, 1)
versionTextLabel.TextSize = 30
versionTextLabel.BackgroundTransparency = 1
versionTextLabel.TextTransparency = 0.75
versionTextLabel.AnchorPoint = Vector2.new(0.5, 1)
versionTextLabel.Position = UDim2.new(0.5, 0, 1, 0)
versionTextLabel.Parent = textLabel

local version = "1.0.0"

local function updateTextLabel(version)
	textLabel.Text = "UPE Build " .. version
end

local function updateVersionTextLabel()
	if game:GetService("RunService"):IsStudio() then
		version = "0.0.0"
	else
		local major, minor, patch = version:match("(%d+)%.(%d+)%.(%d+)")
		if patch == "9" then
			version = major .. "." .. tostring(tonumber(minor) + 1) .. ".0"
		else
			version = major .. "." .. minor .. "." .. tostring(tonumber(patch) + 1)
		end
	end

	versionTextLabel.Text = "Version ALPHA " .. version
end

local function checkPlaceVersionChange()
	if game.PlaceVersion ~= version then
		version = game.PlaceVersion
		updateTextLabel(version)
		updateVersionTextLabel()
	end
end

updateTextLabel(game.PlaceVersion)
updateVersionTextLabel()

textLabel.AnchorPoint = Vector2.new(0.5, 1)
textLabel.Position = UDim2.new(0.5, 0, 1, -30)

game:GetService("RunService").Heartbeat:Connect(checkPlaceVersionChange)

Path:
image

You update version but you don’t seem to be setting the value back to game.PlaceVersion at any point.

I know you didn’t ask for an alternative but I may have gotten carried away thinking about one after seeing the Regex.

You could use a table with three (or more) values instead of Regex’n a single string and manipulating it. Store the data in a table and build the string when you need from whatever values you have stored in the table. Should be easier to increment (if you stick to numbers only) but also gives you the flexiblity of using more complicated strings if you wanted. It would probably also remove the need for the casts (eg. tostring, tonumber).

You could have “extra” decimal points or pretty much anything you want in each string. You won’t need to Regex over the string to pull your values, they are each stored at their own index as string, int or number in the table so each can be as complex (or not) as you like. You could also add a few extra items into the versionArray for things like, the previous version numbers, the date/time it was last updated, who updated it, Alpha/Beta/Release prefixes or suffixes, etc…

--Example using an array to store version details, untested.

versionArray = { major, minor, patch }
-- so versionArray[1] = major, versionArray[2] = minor, versionArray[3] = patch

GetVersion()
function GetVersion()
    return versionArray[1] .. "." .. versionArray[2] .. "." .. versionArray[3]
end

SetVersion(1, 0, 4) --sets all three to provided args
SetVersion(1, 2, 3.7) --3.7 maybe a sub-version to the patch
SetVersion("Bob-2.0", "Mink", "MuchCoolerCodeNameV1") -- all options, but you can't as easily increment those.
function SetVersion( major, minor, patch)
    versionArray[1] = major
    versionArray[2] = minor
    versionArray[3] = patch
    SaveVersion()
end

IncrementMajorVersion() --only currently useful if you stick to numeric values 
function IncrementMajorVersion()
    versionArray[1] += 1
    SaveVersion()
end

SaveVersion()
function SaveVersion()
    game.PlaceVersion = versionArray --presumes PlaceVersion is now a table stored somewhere non-volatile like a datastore.
end

An IncrementMinorVersion() and IncrementPatchVersion() function would be pretty much the same as IncrementMajorVersion() with an added if to increment the upper version by one if at 9 then reset the current version item to 0.

IncrementMinorVersion()
function IncrementMinorVersion()
    versionArray[2] += 1 --Add one to the current value
    if versionArray[2] > 9 then --if now over 9, bump the upper version and reset to 0
        IncrementMajorVersion()
        versionArray[2] = 0
    end
    SaveVersion()
end

There are all sorts of other improvements to my example code that could be made (like type checking for numbers vs int vs string before saving) but hopefully that explains the idea well enough if you wanted to try it out.

Hope it helps you somehow.