This has been happening a lot to me lately and I've tried everything that I could think of.

It was working fine before whenever I tested it but now it just says this:

ShopUI is not a valid member of ScreenGui

even though it is?

error happens on line 19

here is the code:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local PlayButton = script.Parent.Container.PLAY
local InventoryButton = script.Parent.Container.INVENTORY
local ShopButton = script.Parent.Container.SHOP
local Version = script.Parent.Container.Version
local Crosshair = script.Parent.Crosshair
local InventoryGUI = script.Parent.InventoryGUI.InventoryGUI
local InventoryButton = script.Parent.Container.INVENTORY
local ShopButton = script.Parent.Container.SHOP
local CloseInventoryButton = script.Parent.InventoryGUI.CloseFrame.CloseINV
local CloseFrame = script.Parent.InventoryGUI.CloseFrame
local IntermissionPlay = script.Parent.Container.INTERMISSIONPLAY
local CannotPlay = script.Parent.Container.CannotPlay

--Shop GUIS--
local ShopGUI = script.Parent.ShopUI
local CurrencyShop = ShopGUI.CurrencyShop
local MiscShop = ShopGUI.MiscShop
local GamepassShop = ShopGUI.GamepassShop
local MiscShopButton = ShopGUI.MiscShopButton
local CurrencyShopButton = ShopGUI.CurrencyShopButton
local GamepassShopButton = ShopGUI.GamepassShopButton
local CloseShop = ShopGUI.CloseShop

ShopGUI.Visible = false
CurrencyShop.Visible = false
MiscShop.Visible = false
GamepassShop.Visible = false
MiscShopButton.Visible = false
CurrencyShopButton.Visible = false
GamepassShopButton.Visible = false
CloseShop.Visible = false
Crosshair.Visible = false
InventoryGUI.Visible = false
CloseFrame.Visible = false
CannotPlay.Visible = false

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.CameraPart.CFrame

InventoryButton.MouseButton1Click:Connect(function()
	InventoryGUI.Visible = true
	PlayButton.Visible = false
	InventoryButton.Visible = false
	ShopButton.Visible = false
	Version.Visible = false
	CloseFrame.Visible = true
	IntermissionPlay.Visible = false
	CannotPlay.Visible = false
end)
	
CloseInventoryButton.MouseButton1Click:Connect(function()
	InventoryGUI.Visible = false
	PlayButton.Visible = true
	InventoryButton.Visible = true
	ShopButton.Visible = true
	Version.Visible = true
	CloseFrame.Visible = false
	IntermissionPlay.Visible = true
end)



PlayButton.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
	PlayButton:Destroy()
	InventoryButton:Destroy()
	ShopButton:Destroy()
	Version:Destroy()
	Player.CameraMode = Enum.CameraMode.LockFirstPerson
	game:GetService( "UserInputService" ). MouseIconEnabled = false
	Crosshair.Visible = true
	IntermissionPlay.Visible = false
end)

IntermissionPlay.MouseButton1Click:Connect(function()
	CannotPlay.Visible = true
	wait(3)
	CannotPlay.Visible = false
end)

ShopButton.MouseButton1Click:Connect(function()
	PlayButton.Visible = false
	InventoryButton.Visible = false
	ShopButton.Visible = false
	Version.Visible = false
	IntermissionPlay.Visible = false
	CannotPlay.Visible = false
	ShopGUI.Visible = true
	CurrencyShop.Visible = true
	CurrencyShopButton.Visible = true
	MiscShopButton.Visible = true
	GamepassShopButton.Visible = true
	CloseShop.Visible = true
	MiscShop.Visible = true
	GamepassShop.Visible = false
	CurrencyShop.Visible = false
end)

CurrencyShopButton.MouseButton1Click:Connect(function()
	CurrencyShop.Visible = true
	MiscShop.Visible = false
	GamepassShopButton.Visible = false
end)

MiscShopButton.MouseButton1Click:Connect(function()
	CurrencyShop.Visible = false
	MiscShop.Visible = true
	GamepassShop.Visible = false
end)

GamepassShopButton.MouseButton1Click:Connect(function()
	CurrencyShop.Visible = false
	MiscShop.Visible = false
	GamepassShop.Visible = true
end)

CloseShop.MouseButton1Click:Connect(function()
	PlayButton.Visible = true
	InventoryButton.Visible = true
	ShopButton.Visible = true
	Version.Visible = true
	IntermissionPlay.Visible = true
	CannotPlay.Visible = false
	ShopGUI.Visible = false
	CurrencyShop.Visible = false
	CurrencyShopButton.Visible = false
	MiscShopButton.Visible = false
	GamepassShopButton.Visible = false
	CloseShop.Visible = false
end)

I've tried everything I did

local ShopGUI = script.Parent:FindFirstChild("ShopUI")

then it would return as nil

local ShopGUI = script.Parent:WaitForChild("ShopUI")

it would tell me infinite yield possible so I did

local ShopGUI = script.Parent:WaitForChild("ShopUI, 10")

then it would still return as nil after 10 seconds

Yes I have checked all the folders, ShopUI is the only "ShopUI" under the ScreenGui

please help me with this script has been the foundation of my game.

I can provide Screenshots of the folders on my discord which is schlotta#6578

please help me if you know how to solve this

2 comments

0

This is way too much code for this problem! Only show the portion that isn't working.

0

I noted where the error was happening :/