When i am in roblox studios just testing it, it works. But in the actual game it does not. I have tried multiple ways of fixing it but failed to figure it out. Here is my code.
ButtonGuiScript = script.Parent.ButtonGuiScript Frame = script.Parent GUI = script.Parent.Parent MainMenuButton = Frame.MainMenuButton MainMenuFrame = script.Parent.Parent:FindFirstChild('MainMenuFrame') StartScreenbutton = Frame.StartScreenButton StartScreenFrame = script.Parent.Parent:FindFirstChild('StartScreenFrame') Inventorybutton = Frame.InventoryButton InventoryFrame = script.Parent.Parent:FindFirstChild('InventoryFrame') function MainMenubuttonClicked() wait(0.1) script.Parent.Parent:FindFirstChild('MainMenuFrame').Visible = true end function StartScreenbuttonClicked() wait(0.1) script.Parent.Parent:FindFirstChild('StartScreenFrame').Visible = true end function InventorybuttonClicked() wait(0.1) script.Parent.Parent:FindFirstChild('InventoryFrame').Visible = true end Inventorybutton.MouseButton1Click:connect(InventorybuttonClicked) MainMenuButton.MouseButton1Click:connect(MainMenubuttonClicked) StartScreenbutton.MouseButton1Click:connect(StartScreenbuttonClicked)
I am getting the following errors inside roblox
-InventoryCloseButton is not a valid member of frame. stack begin script 'Players.jo3thebomb.PlayerGui.MainScreenGui.InventoryFrame.InventoryGuiScript'. - stack end
-ShopButton is not a valid member of frame. stack begin script 'Players.jo3thebomb.PlayerGui.MainScreenGui.MainMenuFrame.MainMenuScript'. - stack end
Add :WaitForChild() on everything, this will make the script wait until the child is found. Your error comes because in studio everything is loaded instantly, in online mode, it has to be downloaded.
I also suggest using local variables, as these are more efficient.
local ButtonGuiScript = script.Parent:WaitForChild("ButtonGuiScript") local Frame = script.Parent local GUI = script.Parent.Parent local MainMenuButton = Frame:WaitForChild("MainMenuButton") local MainMenuFrame = script.Parent.Parent:WaitForChild("MainMenuFrame") local StartScreenbutton = Frame:WaitForChild("StartScreenButton") local StartScreenFrame = script.Parent.Parent:WaitForChild("StartScreenFrame") local Inventorybutton = Frame:WaitForChild("InventoryButton") local InventoryFrame = script.Parent.Parent:WaitForChild("InventoryFrame")
What you didn't do was add locals. Locals are what substitutes something for something else, and this is one core thing you left out.
local ButtonGuiScript = script.Parent.ButtonGuiScript local Frame = script.Parent local GUI = script.Parent.Parent local MainMenuButton = Frame.MainMenuButton local MainMenuFrame = script.Parent.Parent:FindFirstChild('MainMenuFrame') local StartScreenbutton = Frame.StartScreenButton local StartScreenFrame = script.Parent.Parent:FindFirstChild('StartScreenFrame') local Inventorybutton = Frame.InventoryButton local InventoryFrame = script.Parent.Parent:FindFirstChild('InventoryFrame')