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

Can you not refer to ReplicatedStorage or ServerStorage from a LocalScript?

Asked by
Maxomega3 106
10 years ago

I tried both, and it errored. Is there any way around this?

4 answers

Log in to vote
2
Answered by
Dummiez 360 Moderation Voter
10 years ago

ReplicatedStorage does work in LocalScripts, as the contents are replicated in the client and server.

local repStorage = game.ReplicatedStorage:findFirstChild("WhateverName")

I've used it in my games.

However, ServerStorage cannot be accessed with LocalScripts, since it is only accessible by server. See here for more about that.

0
Haha, I was just about to ask about that. Thanks for the edit. Maxomega3 106 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Using ServerStorage should work from a LocalScript, I have used it in LocalScripts. Was the error that you were referring to ServerStorage, or something else?

0
Well, in ServerStorage, I got that it wasn't a valid member of DataModel (a fancy name for game). And for ReplicatedStorage (which is what I'm really trying to index), I got attempt to index ReplicatedStorage (a userdata value). Yeah. Maxomega3 106 — 10y
0
ServerStorage is a server-only object. Dummiez 360 — 10y
Log in to vote
0
Answered by
Maxomega3 106
10 years ago

I still get the error (see OP) when I try to index Replicated Storage.

Here's my code:

for s in shopitems.Value:gmatch("%P+") do
    if inventory.Value:gmatch(s) then -- errors
        game.ReplicatedStorage(s):clone().Parent = player.Backpack
    end
end
0
Any ideas as to what can be the problem? Maxomega3 106 — 10y
Log in to vote
0
Answered by 9 years ago

If it actually makes it to line 3, change the parenthesis to brackets on game.Replicatedstorage, and capitalize Clone:

game.ReplicatedStorage[s]:Clone().Parent = player.Backpack

Answer this question