How to fix this error?

Here’s the error:

Players.Auevi.PlayerScripts.LocalScript:85: attempt to index nil with ‘FindFirstChild’

local ReplicatedStorage = game:GetService("ReplicatedStorage")
--local UserInput = game:GetService("UserInputService")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local mainGui = AvatarEditor:FindFirstChild("AvatarEditorGui")
local editorFrame = mainGui:FindFirstChild("Frame")["Editor"] 
-- above is the specific line
local footer = editorFrame.Footer
local doneButton = footer.Done

local Debounce = false

AvatarPart.Touched:Connect(function(hit)
	if not Debounce then
		Debounce = true
		AE:Load()
	else
		if doneButton.Activated then 
	AE:Destroy()
		Debounce = false
		end
		end
end)

AvatarEditorGui and Frame are valid?, if are valid, use WaitForChild

local mainGui = AvatarEditor:WaitForChild("AvatarEditorGui")
local editorFrame = mainGui:WaitForChild("Frame")["Editor"] 
1 Like

Now I’m getting this error:

Players.Auevi.PlayerScripts.LocalScript:86: attempt to index nil with ‘WaitForChild’

How am I able to see if AvatarEditorGui and Frame are valid?

EDIT: From my current understanding of what valid means, they’re valid. AvatarEditorGui is a child/member of mainGui and Frame is a child/member of editorFrame.

Okay, I added the WaitForChild to both and now they work; however, now I’m getting this error:

Infinite yield possible on ‘ReplicatedStorage.AvatarEditor:WaitForChild(“AvatarEditorGui”)’

Does it mean that it expects the object, so the object with the exact name really exists at that location?

1 Like

Here’s a picture of my Explorer:

An object named AvatarEditorGui exists at that location, I believe.