Loading Screen isnt working in game

My game which is coming out soon, most stuff are done. I have encountered a problem with my loading screen. The code seems to be fine in studio, but in game, the logo doesnt load like its supposed to. Here is the code.

--// Services

local ReplicatedFirst = game:GetService('ReplicatedFirst')
local TS = game:GetService('TweenService')
local Players = game:GetService('Players')

--// Variables
local player = Players.LocalPlayer
local playerGui = player:WaitForChild('PlayerGui')
local rotation = {}
rotation.Rotation = 5 
local tweenInfo = TweenInfo.new(
	1.2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	-1,
	true,
	0
)

local screenUI = ReplicatedFirst:FindFirstChild('LoadingScreen')
screenUI.IgnoreGuiInset = true
screenUI.Parent = playerGui

playerGui:WaitForChild('Points').Enabled = false
playerGui:WaitForChild('UI').Enabled = false
playerGui:WaitForChild('MainUI').Enabled = false

local backFrame = playerGui:WaitForChild('LoadingScreen').BackFrame
local imageToTween = backFrame.WaterLabel
local textToChange = backFrame.Loaded
local tween1 = TS:Create(imageToTween, tweenInfo, rotation)
local tween2 = TS:Create(imageToTween, tweenInfo, {Rotation = -5})

textToChange.Text = "Loading.."

ReplicatedFirst:RemoveDefaultLoadingScreen()

tween1:Play()
tween2:Play()


wait(5)

if not game:IsLoaded() then
	game.Loaded:Wait()
end

textToChange.Text = "Loaded!"
print('Loaded!')
backFrame:TweenPosition(UDim2.new(0.5,0,-5,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 2)
wait(1)
screenUI:Destroy()
playerGui:WaitForChild('Points').Enabled = true
playerGui:WaitForChild('UI').Enabled = true
playerGui:WaitForChild('MainUI').Enabled = true

So whats happening with my code? Any help would be nice :))

1 Like

Still need some help!

(char)

1 Like

I’ll give it a shot, can you send me a picture of your explorer with all relevant objects so I can replicate the issue?

Like wdym revelant objects? It is just a gui with a frame and image label lol

The script is in the ReplicatedFirst?

Yeah, it used parts of the developer hub which recommended the script be placed in replicated first so I can remove the default loading screen.

Put ReplicatedFirst:RemoveDefaultLoadingScreen() line 1

Tried it, the issues still seems to persist.

An image of the heritage of all the objects like gui’s frames and scripts, I need to recreate it myself so I can see what the problem is

image

1 Like

See if it’s your code or it’s the image not loading while in-game.

If it doesn’t work, try using PreloadAsync().

So this is the exact script I used:

--// Services
--// Services

local ReplicatedFirst = game:GetService('ReplicatedFirst')
local TS = game:GetService('TweenService')
local Players = game:GetService('Players')

--// Variables
local player = Players.LocalPlayer
local playerGui = player:WaitForChild('PlayerGui')
local rotation = {}
rotation.Rotation = 5 
local tweenInfo = TweenInfo.new(
	1.2,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	-1,
	true,
	0
)

local screenUI = ReplicatedFirst:FindFirstChild('LoadingScreen')
screenUI.IgnoreGuiInset = true
screenUI.Parent = playerGui

--playerGui:WaitForChild('Points').Enabled = false
--playerGui:WaitForChild('UI').Enabled = false
--playerGui:WaitForChild('MainUI').Enabled = false

local backFrame = playerGui:WaitForChild('LoadingScreen').BackFrame
local imageToTween = backFrame.WaterLabel
local textToChange = backFrame.WaterLabel.Loaded
local tween1 = TS:Create(imageToTween, tweenInfo, rotation)
local tween2 = TS:Create(imageToTween, tweenInfo, {Rotation = -5})

textToChange.Text = "Loading.."

ReplicatedFirst:RemoveDefaultLoadingScreen()

tween1:Play()
tween2:Play()

wait(5)

if not game:IsLoaded() then
	game.Loaded:Wait()
end

textToChange.Text = "Loaded!"
print('Loaded!')
wait(2.35)
backFrame:TweenPosition(UDim2.new(0.5,0,-5,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 2)
wait(2)
screenUI:Destroy()

playerGui:WaitForChild('Points').Enabled = true
playerGui:WaitForChild('UI').Enabled = true
playerGui:WaitForChild('MainUI').Enabled = true

And I made a little loading screen out of the objects you have (just without the localization tables)
image

And I got this result
https://gyazo.com/59d371ffe0f318f221c695d28d7fa5d5
(the tweening was a lot smoother but the gif made it look choppy)

It didnt work. It will work in studio but in game, it doesnt run right.

I ran it in-game and got this:
https://gyazo.com/2862d802111babb52416290834aba795
So at this point I haven’t a clue what could be causing the problem. Maybe the position of the ui objects?

My position is 0.5,0,0.5,0 The Zindex for the BackFrame is 99, the ImageLabel is 100 and the text labels zindex is 999999999

Once again it loaded just fine (in-game). Can I see exactly how it’s not loading properly with a screenshot or video?

That looks good! Why isn’t that how you’d want it to load?

The image is supposed to be in the center. Let me show you studio recordings.

1 Like