Need help with loading screen

I am testing a loading screen for a simulator I’m making. It isn’t working, and I’m getting an error that says:
ReplicatedFirst.LoadingScreen:14: Expected ')' (to close '(' at column 51), got '='

Here’s the script:

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local localplr = game:GetService("Players").LocalPlayer
local gui = script.LoadingScreen:Clone()
local loadingMessage = {"test1,test2"}
local randomValue = loadingMessage[math.random(1,#loadingMessage)]
local seconds = 0
gui.Parent = PlayerGui

ReplicatedFirst:RemoveDefaultLoadingScreen()

repeat
	if randomValue == "test1" then
		gui.MainFrame.Status.Text = randomValue.."? ("..(seconds = seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."?? ("..(seconds = seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."??? ("..(seconds = seconds + 1)..")"
		wait(1)
	elseif randomValue == "test2" then
		gui.MainFrame.Status.Text = randomValue..". ("..(seconds = seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue..".. ("..(seconds = seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."... ("..(seconds = seconds + 1)..")"
		wait(1)
	end
until game:IsLoaded()

wait(1)
gui.MainFrame:TweenPosition(UDim2.new(0,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)
wait(1)
gui:Destroy()
PlayerGui:WaitForChild("Intro"):WaitForChild("MainFrame"):TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)```
If I need any more information than this, please point that out to me.
1 Like

You can’t have two assignment operators (=) in a statement. Also, there’s an easier way to do this than just repeating yourself. This is what it should like like in the repeat loop.

gui.MainFrame.Status.Text = randomValue .. (("?"):rep((seconds % 3) + 1) .. "("..seconds..")"
seconds = seconds + 1

EDIT: There were some other things I had to fix in this

2 Likes

Done two fixes and it should work fine.

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local localplr = game:GetService("Players").LocalPlayer
local gui = script.LoadingScreen:Clone()
local loadingMessage = {"test1", "test2"} -- FIX
local randomValue = loadingMessage[math.random(1,#loadingMessage)]
local seconds = 0
gui.Parent = PlayerGui

ReplicatedFirst:RemoveDefaultLoadingScreen()

repeat
	if randomValue == "test1" then
		gui.MainFrame.Status.Text = randomValue.."? ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."?? ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."??? ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
	elseif randomValue == "test2" then
		gui.MainFrame.Status.Text = randomValue..". ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
		gui.MainFrame.Status.Text = randomValue..".. ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."... ("..(seconds)..")"
        seconds = seconds + 1
		wait(1)
	end
until game:IsLoaded()

wait(1)
gui.MainFrame:TweenPosition(UDim2.new(0,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)
wait(1)
gui:Destroy()
PlayerGui:WaitForChild("Intro"):WaitForChild("MainFrame"):TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)
2 Likes

Starting to work so much better, thanks! Only problem is that the seconds value doesn’t seem to be going up.

1 Like

Show the code that you have now so we can find a solution.

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local localplr = game:GetService("Players").LocalPlayer
local gui = script.LoadingScreen:Clone()
local loadingMessage = {"test1","test2"}
local randomValue = loadingMessage[math.random(1,#loadingMessage)]
local seconds = 0
gui.Parent = PlayerGui

ReplicatedFirst:RemoveDefaultLoadingScreen()

repeat
	if randomValue == "test1" then
		gui.MainFrame.Status.Text = randomValue.."? ("..(seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."?? ("..(seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."??? ("..(seconds + 1)..")"
		wait(1)
	elseif randomValue == "test2" then
		gui.MainFrame.Status.Text = randomValue..". ("..(seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue..".. ("..(seconds + 1)..")"
		wait(1)
		gui.MainFrame.Status.Text = randomValue.."... ("..(seconds + 1)..")"
		wait(1)
	end
until game:IsLoaded()

wait(1)
gui.MainFrame:TweenPosition(UDim2.new(0,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)
wait(1)
gui:Destroy()
PlayerGui:WaitForChild("Intro"):WaitForChild("MainFrame"):TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.5,false)```

You’re not reassigning the value ‘seconds’ as shown by @Kacper, you need to redefine the value after making changes. I would suggest you just use the code they shared.