In my game sometimes, very rarely, a very curious error comes out that I don’t understand why it happens.
“Players.Player.PlayerGui.LobbyGui.Frames.Inventory.Inventory:67: attempt to index field ‘Parent’ (a nil value)” and “Players.Player.PlayerGui.LobbyGui.Frames.Shop.Shop:69: attempt to index field ‘Parent’ (a nil value)”
This error comes out in the script of the Inventory and Shop gui in exactly the same way.
local inventoryButton = frame.Parent.Parent:WaitForChild("Buttons"):WaitForChild("InventoryButton")
inventoryButton.MouseButton1Down:connect(otherButtonDown)
local shopButton = frame.Parent.Parent:WaitForChild("Buttons"):WaitForChild("ShopButton")
shopButton.MouseButton1Down:connect(otherButtonDown)
local spectateButton = frame.Parent.Parent:WaitForChild("Buttons"):WaitForChild("SpectateButton")
spectateButton.MouseButton1Down:connect(otherButtonDown)
local configButton = frame.Parent.Parent:WaitForChild("Buttons"):WaitForChild("ConfigButton") --ERROR
configButton.MouseButton1Down:connect(otherButtonDown)
That portion of the Script is in both the Inventory and Shop Script, and here is an image of the Explorer.
The error comes out in the line with “local configButton”, what seems strange to me is that it doesn’t come out in the previous ones, which also have “script.Parent.Parent” but they works.
Does anyone know why this is happening? I’ve checked and the Parent is never changed.