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

Why is this string value not changing for every script?

Asked by 7 years ago

Hello! I have a string value in Replicated Storage called 'Target' and it needs to be accessed by a server script. I use;

local Target = game.ReplicatedStorage.Target

In both scripts. It's changed in a script after a button is clicked and I used print to see if it really had changed, sure enough it returned the correct value after clicking the button. I then used the same print test in the server script and it could not find a value in Target at all. Are string Value's accessible? Have I set it up wrong? Should I use a WaitForChild()?

0
I would recommend putting the value in workspace. Preferably in a folder in workspace. FiredDusk 1466 — 7y
0
Would that change anything? Samstergizmo 28 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Well, when finding StringValues I usually use WaitForChild()

so try this;

If the script is in WorkSpace or ServerScriptService

local Target = game.ReplicatedStorage:WaitForChild("Target")
print(Target.Value)

This will print the Target's value and you would know if it actually changed or not,

0
Thanks, but do you know why it isn't fetching the Target value in any script other than the one I set it in Samstergizmo 28 — 7y
0
What other script are you trying BlackOrange3343 2676 — 7y
0
The only one that somehow can access it is a localscript that can change the value. Any other script returns that value as nil Samstergizmo 28 — 7y
Ad

Answer this question