Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Loading screen working but is giving an error and cloning a welcome gui twice, why?

Asked by 5 years ago
Edited 5 years ago

So basically this is my script for my loading screen but whenever I play the game it gives this error: Players.TypicallyPacific.PlayerGui.LoadingGUI.LocalScript:9: attempt to index field 'Parent' (a nil value). Also, it clones the Welcome GUI twice. Why is this happening?

local contentprovider = game.ContentProvider
local player = game.Players.LocalPlayer

while wait() do
    if contentprovider.RequestQueueSize == 0 then
        local gui2 = game.ReplicatedStorage:WaitForChild("Welcome")
        gui2:Clone().Parent = player.PlayerGui
        script.Parent.Frame:TweenPosition(UDim2.new(-1,0,0,0),"In","Quart",1)
        script.Parent.Frame2:TweenPosition(UDim2.new(-1,0,0,0),"In","Quart",1)
        script.Parent.Parent.Welcome.Frame:TweenPosition(UDim2.new(0,0,0,0), "Out", "Quart", 0.75)
        script.Parent.Parent.Welcome.Frame2:TweenPosition(UDim2.new(0,0,-0.1,0), "Out", "Quart", 0.75)
        script.Parent.Parent.Welcome.BlockBattle:TweenPosition(UDim2.new(.125, 0, 0.25, 0), "Out", "Quart", 0.75)
        script.Parent.Parent.Welcome.TextLabel:TweenPosition(UDim2.new(.125, 0, 0.125, 0), "Out", "Quart", 0.75)
        wait(1)
        script.Parent:Destroy()
    end
end
0
The script still works though, except for cloning the gui twice. TypicallyPacific 61 — 5y
1
You need to add a 'break' after destroying the script, or the loop may run again Ziffixture 6913 — 5y
0
Thanks. TypicallyPacific 61 — 5y
0
I think its because there is no parent. That's a bit strange though Mr_Unlucky 1085 — 5y
0
use while true do wait() end, while wait() do end is not a good way yHasteeD 1819 — 5y

Answer this question