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

Is there a way to convert a string into the same location instance?

Thanks for viewing my question.

So is there a way to convert string to instance such as converting “game.Workspace.testfolder” into game.Workspace.testfolder so you can do something such as:

location = converttoinstance(“game.Workspace.testfolder")— function you convert
test = instance.new(“Part”)
test.Parent = location

2 answers

✓ Accepted answer

Hmmm... I think this is the most efficient way of doing it...

local string = "testfolder" --assigns a string to a variable
local instance = game.Workspace:FindFirstChild(string) --finds the instance that has the same name as the string

or...

local instance = game.Workspace:FindFirstChild("testfolder")

But to know answer your question tho, I don't think there is another way of converting string to an instance. Hope this helps! :>

1 comment

0

Thanks! It helps! SMORT idea!

What you can do is like:

string1 = "Part"--Write the name of the Instance you want to create

local NewInstance = Instance.new(string1) --This will make a Part
NewInstance.Parent = workspace --You need to set the parent of the Instance too

I hope this helps

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