Version checker script not working

Hello, I’m trying to make a small GUI in the bottom left that has the place version and will tell you if the server is up to date. While making this the script is working except it’s not updating when the script is out of date and continues to say the script is up to date. (I apologize for the terrible code, it’s the first time I’ve ever done one without a tutorial.)

local StarterGui = game:GetService("StarterGui")

-- create a screenGui
local versionGui = Instance.new("ScreenGui")

-- create a textLabel
local textLabel = Instance.new("TextLabel")

-- position in the bottom right corner
textLabel.Position = UDim2.new(0, 0, 1, 0)
textLabel.AnchorPoint = Vector2.new(0, 1)
textLabel.Size = UDim2.new(0, 150, 0, 40)

-- configure the text settings
textLabel.BackgroundTransparency = 1
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.TextStrokeTransparency = 0
textLabel.TextXAlignment = Enum.TextXAlignment.Left
textLabel.TextScaled = true

-- display the version number
local placeVersion = game.PlaceVersion
textLabel.Text = string.format("Server version: %s", placeVersion)
textLabel.Parent = versionGui

-- parent to the StarterGui
versionGui.Parent = StarterGui


	-- Creating stuff
	local VersionCheckerGui = Instance.new("ScreenGui")
local VersionLabel = Instance.new("TextLabel")
	
	-- Setting stuff up
	
	VersionLabel.Position = UDim2.new(0, 0, 1, -40)
	VersionLabel.AnchorPoint = Vector2.new(0, 1)
	VersionLabel.Size = UDim2.new(0, 150, 0, 40)
	VersionLabel.BackgroundTransparency = 1
	VersionLabel.TextStrokeTransparency = 0
	VersionLabel.TextXAlignment = Enum.TextXAlignment.Left
	VersionLabel.TextScaled = true
-- Checking Stuff
while true do
	print("Server Version has been checked!")
	if placeVersion == game.PlaceVersion then
	VersionLabel.TextColor3 = Color3.new(0, 0.666667, 0)
	
	-- Activating the stuff
	VersionLabel.Text = string.format("Server is up to date!")
	VersionLabel.Parent = VersionCheckerGui
		VersionCheckerGui.Parent = StarterGui
		print(placeVersion)
		wait(20.0)
else if placeVersion ~= game.PlaceVersion then
		VersionLabel.TextColor3 = Color3.new(0.666667, 0, 0)
		--ACTIVATING stuff again
		VersionLabel.Text = string.format("Server is out of date!")
		VersionLabel.Parent = VersionCheckerGui
			VersionCheckerGui.Parent = StarterGui
			print(placeVersion)
		end
	end
end

Note: The prints are just for me to debug it by using the console log.
What I think the issue is that game.placeversion doesn’t check with the Roblox API for the placeversion but instead the server. How would I go about fixing this?

else if

This should be.

elseif
1 Like

Servers continue running the same game version, even when you update the game.
game.PlaceVersion won’t update in every server when you publish an update.

1 Like

Still not updating the text. I assume this is because game.placeVersion doesn’t update with the server.

Oh, would there be a way to get the game version from the Roblox API?

Yeah, that was just a general issue I noticed.

Avoid doing else if in code where elseif should be used instead.

I believe there is a way, but Roblox scripts cannot directly access the API.
You would need to set up a remote server.

Another option is to update a DataStore when the server starts and check whether the current version is newer than the saved version.
You could query this every minute in every server to see if there is a newer version.

1 Like

I was just thinking about using datastores. I’ll go put some code together and see if it works.