Success bar problem

Local1, for start fight:

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.Camera

local TweenService = game:GetService("TweenService")
local rp = game:GetService("ReplicatedStorage")
local starterGui = game:GetService("StarterGui")

local tpParts = {
	workspace.mapsForFight.Map1,
	workspace.mapsForFight.Map2,
	workspace.mapsForFight.Map3,
	workspace.mapsForFight.Map4
}


game:GetService("ReplicatedStorage"):WaitForChild("Remotes").startFight.OnClientEvent:Connect(function(Enemy)
	local enemyName = Enemy.Name
	rp:WaitForChild("Settings").canTrain.Value = false
	
	local gui = game:GetService("Players").LocalPlayer.PlayerGui.FightGui
	gui.EnemyName.Value = enemyName -- ЗАКИДЫВАЕМ ИМЯ ВРАГА В НАШЕ ГУИ
	
	local prompt = Enemy:WaitForChild("ProximityPrompt")
	
	local function countDown()
		
		game:GetService("SoundService").CountdownFight:Play()
		
		local Text = gui.StartFightText
		Text.Text = "3"
		Text.Visible = true
		Text.TextTransparency = 0
		Text.UIStroke.Transparency = 0
		Text.TextSize = 100

		local tween = TweenService:Create(
			Text,
			TweenInfo.new(0.3),
			{TextSize = 80}
		)

		tween:Play()
		
		wait(0.2)
		
		Text.TextTransparency = 1
		Text.UIStroke.Transparency = 1
		
		Text.Visible = false
		
		wait(0.7)

		Text.Text = "2"
		Text.TextTransparency = 0
		Text.UIStroke.Transparency = 0
		Text.TextSize = 100
		
		Text.Visible = true
		
		tween:Play()
		
		wait(0.2)
		
		Text.TextTransparency = 1
		Text.UIStroke.Transparency = 1

		Text.Visible = false
		
		wait(0.7)

		Text.Text = "1"
		Text.TextTransparency = 0
		Text.UIStroke.Transparency = 0
		Text.TextSize = 100
		Text.Visible = true
		
		tween:Play()

		wait(0.2)
		
		Text.TextTransparency = 1
		Text.UIStroke.Transparency = 1

		Text.Visible = false
		
		wait(0.7)

		Text.Text = "GO!"
		Text.TextTransparency = 0
		Text.UIStroke.Transparency = 0
		Text.TextSize = 100
		Text.Visible = true

		tween:Play()
		
		wait(0.2)
		
		Text.TextTransparency = 1
		Text.UIStroke.Transparency = 1
		Text.Visible = false
		
	end
	
	gui.Enabled = true
	
	local randomPlace = math.random(1, #tpParts)
	local randomTpPart = tpParts[randomPlace]
	local enemyClone = Enemy:Clone()
	enemyClone.Name = "EnemyClone"
	enemyClone.Parent = workspace.clones
	enemyClone.ProximityPrompt:Destroy()
	enemyClone.Description:Destroy()
	enemyClone.recommended:Destroy()
	
	local currentMap = Instance.new("StringValue")
	currentMap.Parent = enemyClone
	currentMap.Name = "CurrentMap"
	currentMap.Value = randomTpPart.Name

	player.Character.HumanoidRootPart.CFrame = randomTpPart.Arena_1.tp.CFrame -- ТП ИГРОКА
	enemyClone.HumanoidRootPart.CFrame = randomTpPart.Arena_1.enemyTp.CFrame -- ТП МОБА
	
	starterGui:SetCore("ResetButtonCallback", false)
	
	
	humanoid.WalkSpeed = 0
	humanoid.JumpHeight = 0
	
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = randomTpPart.Arena_1.currentCamera.CFrame
	
	gui.Parent.MainButtons.Enabled = false
	gui.Parent.codeGUI.Enabled = false
	
	wait(0.2)
	
	countDown()
	
	local tool = player.Character:FindFirstChildOfClass("Tool")
	if tool then
		tool.Handle.Transparency = 1
	end
	
	gui.Parent.LocalScripts.FightingScript.Enabled = true
end)

FightingLocal:

					--ПОЛУЧАЕМ ПЕРЕМЕННЫЕ И ТД.
local ui = game:GetService("UserInputService")
local tween = game:GetService("TweenService")
local rp = game:GetService("ReplicatedStorage")
local mps = game:GetService("MarketplaceService")
local starterGui = game:GetService("StarterGui")
local soundService = game:GetService("SoundService")

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded
local humanoid = character.Humanoid

local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local cameraCf = camera.CFrame

local gui = script.Parent.Parent.FightGui
local clickFrame = gui.clickFrame
local backFrame = gui.back
local frontFrame = gui.front

local setting = rp:WaitForChild("Settings")

local animP = rp:WaitForChild("Animations"):WaitForChild("FightAnim")
local loadP = humanoid:LoadAnimation(animP)
local animPLost = rp:WaitForChild("Animations"):WaitForChild("PlayerLostE")
local loadPLost = humanoid:LoadAnimation(animPLost)
local animPWin = rp:WaitForChild("Animations"):WaitForChild("PlayerWinP")
local loadPWin = humanoid:LoadAnimation(animPWin)

local plusText = script.Parent.Parent.UnderGui.plusWins
plusText.TextTransparency = 1
plusText.UIStroke.Transparency = 1

local camera = workspace.Camera

wait(0.4)

local enemyName = gui.EnemyName.Value
local enemy = workspace.clones:WaitForChild("EnemyClone")
local mapName = enemy:WaitForChild("CurrentMap").Value
local map = workspace.mapsForFight:FindFirstChild(mapName)

local currentCamera = map:WaitForChild("Arena_1").currentCamera

local enemyAnimFight = rp:WaitForChild("Animations"):WaitForChild("FightAnimEnemy")
local enemyLoadFight = enemy:FindFirstChild("Humanoid"):LoadAnimation(enemyAnimFight)
local enemyWin = rp:WaitForChild("Animations"):WaitForChild("EnemyWinE")
local enemyWinLoad = enemy:FindFirstChild("Humanoid"):LoadAnimation(enemyWin)
local enemyLost = rp:WaitForChild("Animations"):WaitForChild("EnemyLostP")
local enemyLostLoad = enemy:FindFirstChild("Humanoid"):LoadAnimation(enemyLost)

enemyLoadFight:Play()

wait(0.2)

local minProgress = 0
local maxProgress = gui.back.Size.X.Scale

local function AttackPower(power, mass)
	local powerMassDiferce = power - mass
	if powerMassDiferce < 0 then
		powerMassDiferce = 0
	end

	if powerMassDiferce > 1000 then
		powerMassDiferce = 1000
	end

	local attack = (powerMassDiferce + math.random(0, 5)) / 10000
	--print(powerMassDiferce, attack)
	local normalizedValue = (attack * (maxProgress - minProgress)) + minProgress
	return normalizedValue
end

local ld = player:WaitForChild("leaderstats")

local playerPower = ld:WaitForChild("Power").Value
local playerMass = ld:WaitForChild("Mass").Value

local enemyPower = enemy:FindFirstChild("Power").Value
local enemyMass = enemy:FindFirstChild("Mass").Value


local playerAttack = AttackPower(playerPower, enemyMass)
local enemyAttack = AttackPower(enemyPower, playerMass)

				-- ДЕЛАЕМ ФУНКЦИЮ КЛИКА

local function click()
	if script.Enabled == true and frontFrame.Size.X.Scale <= backFrame.Size.X.Scale then
		frontFrame.Size += UDim2.new(playerAttack, 0, 0, 0) -- АТАКУЕТ ИГРОК
		if camera.FieldOfView >= 30 then
			camera.FieldOfView -= setting.cameraMovePlayer.Value
		else
			camera.FieldOfView = 30
		end
	end
end

mouse.Button1Down:Connect(click)
ui.TouchTap:Connect(click)

				-- ФИГАЧИТ БОТ

while wait(setting.EnemyTimeHit.Value) and script.Enabled == true do -- НАСТРОЙКА ТОГО КАК ЧАСТО БЪЕТ БОТ НАЗЫВАЕТСЯ: EnemyTimeHit
	
	gui.Enabled = true
	frontFrame.Size -= UDim2.new(enemyAttack, 0, 0, 0) -- АТАКУЕТ ВРАГ
	--camera.FieldOfView += setting.cameraMoveEnemy.Value
	camera.FieldOfView += enemyAttack
	loadP:Play()
	
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = currentCamera.CFrame
	
	enemyLoadFight:Play()
	
	if frontFrame.Size.X.Scale >= backFrame.Size.X.Scale then -- ПРОВЕРЯЕМ ДОШЛА ЛИ ЗЕЛЕНАЯ ПОЛОСКА ДО КРАСНОЙ
		--print("you won")
		soundService.WinSound:Play()
		
		if mps:UserOwnsGamePassAsync(player.UserId, 228446905) then
			player.leaderstats.Wins.Value += enemy.Reward.Value * 2 * math.ceil(player:WaitForChild("Buffs"):WaitForChild("Wins").Value)
			--print("reward with")
			plusText.Text = "🏆+".. enemy.Reward.Value * 2 * math.ceil(player:WaitForChild("Buffs"):WaitForChild("Wins").Value)
			plusText.Visible = true
		else
			player.leaderstats.Wins.Value += enemy.Reward.Value * math.ceil(player:WaitForChild("Buffs"):WaitForChild("Wins").Value)
			plusText.Text = "🏆+".. enemy.Reward.Value * math.ceil(player:WaitForChild("Buffs"):WaitForChild("Wins").Value)
			plusText.Visible = true
			--print("reward without")
		end
		
		local Info = TweenInfo.new(0.6)
		local Info2 = TweenInfo.new(0.6)
		local Tween = tween:Create(plusText, Info, {TextTransparency=0})
		local Tween2 = tween:Create(plusText.UIStroke, Info, {Transparency=0})
		local tween3 = tween:Create(plusText, Info2, {Position = script.Parent.Parent.UnderGui.Wins.Position})
		
		Tween:Play()
		Tween2:Play()
		
		enemyLostLoad:Play()
		loadPWin:Play()
		
		frontFrame.Size = UDim2.new(maxProgress / 2 ,0, 0.08, 0)
		
		camera.FieldOfView = 70
		script.Enabled = false 
		
		wait(0.4)
		
		tween3:Play()
		game:GetService("SoundService").plusMoney:Play()
		
		wait(0.6)
		
		plusText.Visible = false		
		loadP:Stop()
		enemyLoadFight:Stop()
		gui.Enabled = false 
		
		wait(0.3)
		
		enemy:Destroy()
		
		local tool = player.Character:FindFirstChildOfClass("Tool")
		if tool then
			tool.Handle.Transparency = 0
		end
		
		wait(0.5)

		humanoid.WalkSpeed = 16
		humanoid.JumpHeight = 7.2
		
		camera.CameraType = Enum.CameraType.Custom
		
		player.Character.HumanoidRootPart.CFrame = workspace.Spawn_Test.SpawnLocation.CFrame
		gui.Parent.UnderGui.Enabled = true
		gui.Parent.MainButtons.Enabled = true
		gui.Parent.codeGUI.Enabled = true
		rp:WaitForChild("Settings").canTrain.Value = true
		starterGui:SetCore("ResetButtonCallback", false)
		
		break -- ЛИВАЕМ
	elseif frontFrame.Size.X.Scale <= 0 then -- ЧТО ЕСЛИ ПРОИГРАЕМ
		
		--print("you lost")
		
		enemyWinLoad:Play()
		loadPLost:Play()
		
		frontFrame.Size = UDim2.new(0.207 ,0, 0.08, 0)
		camera.FieldOfView = 70
		script.Enabled = false 
		
		loadP:Stop()
		enemyLoadFight:Stop()
		
		local tool = player.Character:FindFirstChildOfClass("Tool")
		if tool then
			tool.Handle.Transparency = 0
		end
		
		gui.Enabled = false
		
		wait(1.1)

		enemy:Destroy()
		
		humanoid.WalkSpeed = 16
		humanoid.JumpHeight = 7.2
		
		camera.CameraType = Enum.CameraType.Custom
		
		player.Character.HumanoidRootPart.CFrame = workspace.Spawn_Test.SpawnLocation.CFrame
		gui.Parent.UnderGui.Enabled = true
		gui.Parent.MainButtons.Enabled = true
		gui.Parent.codeGUI.Enabled = true
		rp:WaitForChild("Settings").canTrain.Value = true
		starterGui:SetCore("ResetButtonCallback", false)
		
		break
	end
end

So let’s start with the fact that I have a script for the same mechanics as the Arm Wrestle simulator. Here’s an example. But for some reason I’m getting bugs like this:



the question is, what’s wrong? If I was testing in studio everything worked fine, but when I decided to publish the game other players encountered these bugs.