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

5 comments

0

The script still works though, except for cloning the gui twice.

1

You need to add a 'break' after destroying the script, or the loop may run again

0

Thanks.

0

I think its because there is no parent. That's a bit strange though

0

use while true do wait() end, while wait() do end is not a good way