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

[closed] How to find value in ServerStorage that my Local Script can't find? [closed]

Asked by
SanityMan 239 Moderation Voter
9 years ago

I am making a script that needs to index a money value given to a player so it can subtract money while a player orders food. Before I describe details, I would like to mention that it works flawlessly in my Roblox Studio tests.

Basically, when a player joins, an initialization script (in ServerScriptService) checks if the player has a money value on the server yet, and if not, it creates a new one (which is placed in a Configuration object in a Folder in ServerStorage --that would be game.ServerStorage.CafeFolder.Money). When the player loads, a script in a GUI runs. It waits (1) and then does this:

local plr = game.Players.LocalPlayer
local name = plr.Name
repeat wait() until game:WaitForChild("ServerStorage"):FindFirstChild("CafeFolder"):FindFirstChild("Money"):WaitForChild(name)
print("Found money")

As you can see, it retrieves the player name (which is used as the name for the money value), then repeats a wait until it can find the value. When it has found the value, it prints "Found money".

The problem is, it doesn't get that far.

It keeps repeating and does not print the message, telling me that for whatever reason, it cannot find the value. I know the value exists because after its creation, the initialization script prints that a money value has been created for the character.

I honestly have no idea how to fix this, because it works perfectly in Studio. I have used the :WaitForChild() method and even added solid wait() times. If you have any idea of how I should go about fixing this, please help.

0
Please do not say [closed] if the question is not actually closed. EzraNehemiah_TF2 3552 — 9y

Locked by EzraNehemiah_TF2 and Goulstem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
2
Answered by 9 years ago

You only have 1 problem, its that you can't access ServerStorage with a localscript! - If you're trying to use a local script to access it, use ReplicatedStorage instead.

Everything else is fine if it works to your expectations in studio!

0
Thank you! I was previously unaware of this! SanityMan 239 — 9y
0
No problem Operation_Meme 890 — 9y
Ad