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

Can I use a Variable after workspace to find stuff in the workspace?

Asked by 3 years ago
Edited 3 years ago

I have a folder in the workspace that i want to reference. The folder is named "Player" Stand. For ex, mcslimeman Stand. I alsohave a variable that is named folder, shown below

local folder = (playerstring..stand)

playerstring is the name of the player, and stand is just " Stand". Can I do local "name" = workspace.folder, so in theory, it would act like workspace.player Stand?

1 answer

Log in to vote
0
Answered by 3 years ago

I don't exactly understand what you're trying to do but if you're trying to find something in the workspace, that probably would work.

For example, I have a model in the workspace called "PhantomBlox27 Stand" and I have a variable of the player name, I could find it by doing this:

local stand = workspace[playerName.. " ".. "Stand"]
0
First of all, thanks, it worked. I just have some remanding questions. why do we use [] instead of like () or .? mcslimeman 37 — 3y
0
I haven't read up on that but I'm assuming it treats the workspace as like an array, so workspace["Part"] would be finding something in the workspace called Part, you can also use workspace:FindFirstChild(playerName.. " ".. "Stand") if you want. ApexBrick 59 — 3y
Ad

Answer this question