Problem with if and elseif

Well, my problem is that the following script is executed 3 times with a FireServer, for each run +1 is added and when it reaches the value 2, it should be executed in a different way but it does not

local loadingScreen = script.Pantallacarga
loadingScreen.Parent = game.Players.LocalPlayer.PlayerGui

local ValorFin = 0

local function FireBarBg(plr, Position, Text) --changed
	if tostring(plr.Name) == tostring(game.Players.LocalPlayer.Name) then
		if ValorFin < 2 then
			loadingScreen.Background.BarBG.Bar:TweenSize((Position), nil, nil, 0.6)
			loadingScreen.Background.Counter.Text = Text
			ValorFin = ValorFin + 1
		elseif ValorFin > 2 then
			loadingScreen.Background.BarBG.Bar:TweenSize((Position), nil, nil, 0.2)
			loadingScreen.Background.Counter.Text = Text
		end
		print(ValorFin)
	end
end


ScreenBarBgGraphicsFire.OnClientEvent:Connect(FireBarBg)

You need to do >= 2 as > 2 means only if it is greater than 2

2 Likes