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

LocalScript not finding variable in it?

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

✓ Accepted answer
script.Parent.Y

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

^^

4 comments

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).

0

can u please screenshot the explorer so i can help better? bcs u said its in the script

0

Well, I did your approach but with "script" instead of "script.Parent" and it works.

0

alr nice

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