I'm making a script where when a gui button is pressed on screen, a tool from ServerStorage is cloned and goes to the player's backpack. The script works in studio test mode, but when playing the published game, I get the error "ServerStorage is not a valid member of Data Model". How do I access the Server Storage from the PlayerGUI? Here is the script.
function give(x)
local y = script.Parent.Parent.Parent.Parent.Parent.Backpack --Player's Backpack
local z = game.ServerStorage["Receipt"] --Problem Area
z:Clone().Parent = y
local gui = y.Parent.PlayerGui.OrderSystem.Order
gui:Clone().Parent = y.Receipt.Tools
local newGui = y.Receipt.Tools.Order --Ignore from here on
newGui.Cancel.Visible = false
newGui.ImageButton1.Visible = false
newGui.ImageButton2.Visible = false
newGui.ImageButton3.Visible = false
newGui.ImageButton4.Visible = false
newGui.Done.Visible = true
end
script.Parent.MouseButton1Click:connect(give)

3 comments
Why gui is in the tool?
The order gui is shown when the tool is equipped, but that's not the part that's having trouble.
:connect() is deprecated, use :Connect()