So, I’ve been working on a Loading Screen for my game, and its’ been working fine for a while, but now I’m having a problem where the loading screen is instantly destroyed once the game loads, without playing the tweens.
I started having this issue right after I changed the ScreenGui’s ZIndexBehavior to Global and changed the Z index of the things inside it to increments of 100(as recommended on the Developer Hub site).
Any help would be very much appreciated!
All the code is in a LocalScript by the way.
My code:
game.ReplicatedFirst:RemoveDefaultLoadingScreen()
local PlayerGUI = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
local GUI = script.LoadingScreen:Clone()
GUI.Parent = PlayerGUI
repeat
for i = 1, 30, 1 do
GUI.Spinner.Rotation += 5
wait(0.03)
end
if GUI.Text.Text == "LOADING." then
GUI.Text.Text = "LOADING.."
elseif GUI.Text.Text == "LOADING.." then
GUI.Text.Text = "LOADING..."
elseif GUI.Text.Text == "LOADING..." then
GUI.Text.Text = "LOADING."
end
until game:IsLoaded() and game.Players.LocalPlayer.Character ~= nil
local tween = game:GetService("TweenService"):Create(GUI.Spinner, TweenInfo.new(1.5), {Rotation = 0})
tween:Play()
local textTween = game:GetService("TweenService"):Create(GUI.Text, TweenInfo.new(1.5), {TextTransparency = 1; TextStrokeTransparency = 1})
textTween:Play()
wait(1.85)
GUI.LeftWall:TweenPosition(UDim2.new(-2,0,0,0),"InOut","Sine",1)
GUI.RightWall:TweenPosition(UDim2.new(3,0,0,0),"InOut","Sine",1)
GUI.Spinner:TweenPosition(UDim2.new(2,0,0,0),"InOut","Sine",1)
wait(2)
GUI:Destroy()
local Number = 0
repeat
Number = Number +1
for i = 1, 30, 1 do
GUI.Spinner.Rotation += 5
wait(0.03)
end
if GUI.Text.Text == "LOADING." then
GUI.Text.Text = "LOADING.."
elseif GUI.Text.Text == "LOADING.." then
GUI.Text.Text = "LOADING..."
elseif GUI.Text.Text == "LOADING..." then
GUI.Text.Text = "LOADING."
end
until game:IsLoaded() and game.Players.LocalPlayer.Character ~= nil and Number.Value >= 5
Okay what the heck. I had the Studio Camera above a block when I was testing before, then I moved the camera away from the block and tested it and now it works, I tried above the block again and it doesn’t then… I tried both with the ZIndex’s changed back to increments of 1.
This has to be a bug(I don’t have access to Bug Report though).(Maybe it has to do with the Block having a Script with a Touched connected Event inside it?)
Maybe you should wait a little longer, the player gui probably loaded and then you loaded when the gui was being destroyed…
that’s estimated 5-10 seconds loading, it usually takes me 10 seconds to load in a game on studio
? I have it so that the Character is not equal to nil(meaning it is in the game and controllable) before doing anything else.
(Also your post seems a bit off-topic.)