Cannot find child in StarterGui, even though it is there

Hey there! So I was scripting a welcome screen for my new game, and I basically wanted this little loading animation I made to come up once the player clicks on the button ‘Play’.

However, when I try to run the script, I get an error saying that my object isn’t a object inside StarterGui.

Here is my StarterGui:
image

Here is the error I receive:

The code below is inside a WelcomeGui, which is in a frame where it runs from a button. I’ll share a picture of how it looks and then I’ll add the code:
image (the LocalScript is inside the frame where this code is stored in)

Code:

local PlayerGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')
local welcomeScreen = script.Parent.Parent.Frame
local loading = game.StarterGui.PlayLoadingScreen.Frame

local playButton = script.Parent.Play
local settingsButton = script.Parent.Settings
local storeButton = script.Parent.Store

playButton.MouseButton1Click:Connect(function()

loading.Parent = PlayerGui

loading.Visible = true
welcomeScreen.Visible = false

wait(9)

loading.Visible = false

end)

Hello. I think I have a solution for your problem.
Could you try replacing this:

local loading = game.StarterGui.PlayLoadingScreen.Frame

To this?

local loading = game.StarterGui:WaitForChild("PlayLoadingScreen").Frame

I am sorry if I am wrong.
Have a nice day.

1 Like

Everything you put in the starterGui replicates into the playergui. If you want to get the frame, do PlayerGui.PlayLoadingScreen.Frame

1 Like

Instead of

local loading = game.StarterGui.PlayLoadingScreen.Frame

You should do

--find the loading screen FROM the Player, not the whole server
loadingScreen = PlayerGui:WaitForChild("PlayLoadingScreen")
---find the frame from the loadingScreen
loadingFrame = loadingScreen.Frame
4 Likes