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

Sorry, having a mind blank. But how would i use a variable, then reference it?

Asked by 4 years ago

Sorry for confusing title. I am having a mind blank and completely forgot how to reference a variable.

So this is what i want to do:

variable = part

workspace.Folder.Model.*variablehere*.item

How would i do this? This isn't my actual script, just some place holders. But i want to set the variable value using remote events from another script, which i have done, then place that into my script. Here is a more accurate representation of what i want to do:

game.ReplicatedStorage.remoteevent.OnClientEvent:Connect(function(variablename)
       variable = variablename
end)


workspace.Folder.Model.*variablehere*.item

Sorry, is this confusing?

Any help would be appreciated.

1 answer

Log in to vote
0
Answered by 4 years ago

To do this use the [] brackets without .. Here is an example:

local part = workspace.Part
workspace[part]:Destroy()

You can also find items/values inside of it using:

local part = workspace.Part
workspace[part].Value:Destroy()

Accept this if it worked/helped you get your final answer.

0
Thanks. It turns out i wasn't having a mind blank. I had tried this already, but the problem wasn't referencing the value, it was the fact that i forgot that i had changed the name of the remote event i used, therefore the value that i wanted to reference was actually nil. Thanks anyway, i accepted ur answer :) Superexperiencedguy 199 — 4y
Ad

Answer this question