I am trying to make a shop for a simplistic banking system. Every time I test it (by creating a test server) the shop won't open due to this error:
"Shop is not a valid member of ScreenGui"
Script 'Players.Player1.PlayerGui.Cash.ShopButton.LocalScript', Line 2
Above ^ is where the code is found inside the local player, but can also be found through
game.StarterGui.Cash.ShopButton.LocalScript
However, it is a child of the ScreenGui, there is no possible way that it is not. Why does it do that?
The code in the Script of which the error occurred in;
ShopB = script.Parent
Shop = game.Players.LocalPlayer.PlayerGui.Cash.Shop
ShopB.MouseButton1Click:connect(function()
if Shop.Visible == false then
Shop.Visible = true
ShopB.Parent.BankFrame.Visible = false
else
Shop.Visible = false
if ShopB.Parent.OpenBank.Text == "Close Bank" then
ShopB.Parent.BankFrame.Visible = true
end
end
end)
Keep in mind: The "Shop" is a Frame. The ScreenGui is named "Cash"
Thanks for the help!

1 comment
Use WaitForChild to wait for the Shop Frame to become available. http://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild