How would I find a variable in a script?

Hello! I am WEcompany. I am trying to create a build mode for my game. What I need help with is finding a variable. For example,

local variable = script.Parent.Parent.Value --Lets just say that this is Yeet for now

print(workspace[[Variable]])

and the expected output should be

Yeet

I looked all over the DevHub and cannot find it. Can you show me how I would be able to print Yeet for example? Thank you, WE

don’t know what your code above is but you could use a table and check the index value

do you mean,

print(workspace[Variable])

edit: You can’t have a dot before a “[”(idk whats this called lol.

You can make use of GetFullName(), so:

print(variable:GetFullName()) -- game.workspace.path
1 Like

Yes. That is what I mean. I just have never learned how to do that.

1 Like

Do you mean

local variable = script.Parent.Variable--Variable itself
local Variable = script.Parent.Variable.Name--The Variable Name
local Variable = script.Parent.Value--The variables value

That is printing as the game name.
image

Is that value a StringValue or an Object Value or a child of script.Parent.Parent?

If it is a StringValue then it should be:

print(workspace[variable])

If it is an ObjectValue then it should be:

print(workspace[variable])

edit: Nevermind, ignore this message. you can do it the same ways lol.

image

If the Value is Yeet, Whatever Your Part is Or Model or another Instance Shoud be Named Yeet.

local Varible = script.Parent.Parent.Value

wait(3)
print(workspace[Varible])

Well I got this error. I think its because it is a localscript.
image
I don’t really want people “stealing” the stuff I am making. I created this as an example.

Here is what I am trying to do:

local oindex = script.Parent.Parent.Parent.Parent.Oindex.Value

script.Parent.InputChanged:Connect(function()
	print(game[oindex]) 
end)

what would your oindex be?
I assume your oindex value would be empty at first, so you may need to set the oindex.

what are you trying to do, Are you making some type of a search thingy?

Is it In workspace or Another Service? You said game[oindex], unless its another service that wont work

oindex is something inside the client. Im creating a build system.

Im trying to create a properties window inside of studio. Im just printing for tests. It is an object value and yes it is empty.

Inside the Player? if Its inside the Player it would be Game

I Would Suggest Using Player or Accessing it Through the Player an not Game

Player:FindFirstChild(oindex)

Well I am trying to modify stuff inside of lighting with this script, for example, ambient.

if you Trying to Get Something Inside of Lighting you would do game.Lighting[oindex]

This is printing Instance
image

What I tried:

local oindex = script.Parent.Parent.Parent.Parent.Oindex.Value

script.Parent.InputChanged:Connect(function()
	print(game:FindFirstChild(oindex).Name) 
end)

I even tried it without name, and oindex.Value is currently equal to Lighting.