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

LocalScript not finding variable in it?

Asked by 5 years ago
Edited 5 years ago

So, I have a "NumberValue" instance called "Y" inside of a LocalScript.

The LocalScript is parented to a TextLabel. And the LocalScript works, it's functional.

However, the LocalScript can't find the "NumberValue" named "Y".

I've tried:

script:FindFirstChild("Y")

script:FindFirstChildOfClass("NumberValue")

script.Parent:FindFirstChildOfClass("LocalScript"):FindFirstChildOfClass("NumberValue")

All of those yield "nil". Yes, I've checked through explorer and "Y" is inside the LocalScript.

I have no idea what may be happening except for a FilteringEnabled issue or the LocalScript not able to index things inside of itself. I haven't tried it indexing other instances in it.

Before you ask about what's inside the script's parent, it's only the script.

Edit1:

I should also mention that, in a separate server-side script, it's able to index the "NumberValue", "Y"

1 answer

Log in to vote
2
Answered by
tacotown2 119
5 years ago
Edited 5 years ago
script.Parent.Y

--and if u made the instance trough a script do
script.Parent:WaitForChild("Y")

^^
0
Well, script.Parent wouldn't work since it'd be looking for "Y" inside the TextLabel and not the script itself, but I'll try it (without .Parent). Cvieyra2test 176 — 5y
0
can u please screenshot the explorer so i can help better? bcs u said its in the script tacotown2 119 — 5y
0
Well, I did your approach but with "script" instead of "script.Parent" and it works. Cvieyra2test 176 — 5y
0
alr nice tacotown2 119 — 5y
Ad

Answer this question