Brick color does not turn green if a certain condition is met

The thing I’m trying to make is that if the checkpoint name is smaller than the players stage value then the part should become green, the issue is the part doesn’t and I have even tried adding a wait but yet still no result, here’s the code it’s inside StarterPlayerScripts

-- // Functions \\ --
local function updateCheckpointColors()
	for _, checkpoint in pairs(Checkpoints:GetChildren()) do
		if checkpoint:IsA("Part") then
			print("Checkpoint: " .. checkpoint.Name .. " Type: " .. typeof(checkpoint.Name))
			print("Stage: " .. leaderstats.Stage.Value .. " Type: " .. typeof(leaderstats.Stage.Value))
			if checkpoint.Name == tostring(leaderstats.Stage.Value + 1) then
				checkpoint.BrickColor = BrickColor.new("Lime green")
			else
				-- if you want to reset the color when they are not on the brick change it here
			end
		end
	end
end

-- // Connections \\ --
leaderstats.Stage.Changed:Connect(updateCheckpointColors)
updateCheckpointColors()
1 Like

Is the checkpoint’s name equal to “1” (or whatever stage value you’re in)

The checkpoint names are in numerical order