Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to access ServerStorage from PlayerGUI?

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

0

Why gui is in the tool?

0

The order gui is shown when the tool is equipped, but that's not the part that's having trouble.

0

:connect() is deprecated, use :Connect()

1 answer

✓ Accepted answer

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.

1 comment

0

It worked thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.