Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to access ServerStorage from PlayerGUI?

Asked by 6 years ago

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)
0
Why gui is in the tool? OnaKat 444 — 6y
0
The order gui is shown when the tool is equipped, but that's not the part that's having trouble. iFizzics 3 — 6y
0
:connect() is deprecated, use :Connect() saSlol2436 716 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

ServerStorage is only accessible via the Server. That is why it's called 'ServerStorage'.

If you want a client to access something, then put it in 'ReplicatedStorage'. This storage both the Server and the Clients can see.

Note: Remember that you also need to use a LocalScript inside the Gui.

0
It worked thank you! iFizzics 3 — 6y
Ad

Answer this question