Attempt to index nil with 'InsertFrame'

I am trying to make a variable for a frame.

It puts out this into the console:

22:35:11.968 - Players.devinkid1.PlayerGui.ScreenGui.InsertSystem:20: attempt to index nil with 'InsertFrame'

Any idea of why this is happening?

This is the code:

local InsertFrame = script.Parent.InsertFrame -- Breaking line
local OpenButton = script.Parent.OpenButton
local InsertButton = InsertFrame.InsertButton
local IdBox = InsertFrame.IdBox
local CloseButton = InsertFrame.CloseButton

This is the layout:

image

Try using script.Parent:WaitForChild(“InsertFrame”) and also confirm that the object InsertFrame exists within the ScreenGui under your player’s PlayerGui.

1 Like

Still not working.

Console:

22:49:01.414 - Players.devinkid1.PlayerGui.ScreenGui.InsertSystem:21: attempt to index nil with 'WaitForChild'

Script:

local InsertService = game:GetService("InsertService")
local Gui = script.Parent
local InsertFrame = Gui:WaitForChild("InsertFrame") -- Breaking line
local OpenButton = Gui:WaitForChild("OpenButton")
local InsertButton = InsertFrame:WaitForChild("InsertButton")
local IdBox = InsertFrame:WaitForChild("IdBox")
local CloseButton = InsertFrame:WaitForChild("CloseButton")

Layout:

image

The New Error says that script.Parent is Nil , Are you deleting the GUI somewhere in any other script? Also try removing that line and see if it works.

2 Likes

Do note that removing your InsertFrame variable will also error out InsertButton, IdBox and CloseButton. Just comment those out and what @Razor_IB said.

Yup, thats why. It is supposed to delete itself if you are not the owner haha

1 Like