I apologise for all the question I have been asking recently, but I just don't know how to fix half this stuff and google isn't helping much.
These scripts are for going from one Gui menu to another. They are pretty much the same script, yet one works and the other comes up with this nil error.
First script that works perfectly:
local CSMenu = game.Players.LocalPlayer.PlayerGui:FindFirstChild("CharacterSelect")
local CSelect = CSMenu.Mainframe
local Startmenu = game.Players.LocalPlayer.PlayerGui:FindFirstChild("StartMenu")
local SM = Startmenu.Frame
local function togglevis()
SM.Visible = false
CSelect.Visible = true
end
script.Parent.MouseButton1Click:Connect(togglevis)
Second script with Local variables changed to fit the next Gui, which doesnt work:
local ShopGui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("Shop")
local Shopmenu = ShopGui.Mainframe
local Startmenu = game.Players.LocalPlayer.PlayerGui:FindFirstChild("StartMenu")
local SM = Startmenu.Frame
local function togglevis()
SM.Visible = false
Shopmenu.Visible = true
end
script.Parent.MouseButton1Click:Connect(togglevis)
The error received with this second script is: "Players.DragonessAnimations.PlayerGui.StartMenu.Frame.Shop.LocalScript:2: attempt to index nil with 'Mainframe'" It occurs on this line: local Shopmenu = ShopGui.Mainframe I honestly don't have the scripting knowledge to understand what this means, I am still trying to learn.
Any help is appreciated.

1 comment
I can't believe it was that easy, now I feel stupid lmao. Thank you!