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

[solved]How to turn string into path?

I am trying to take a string(such as "game.Workspace") and use it as a path. How can I do this?

C_ROOT = script:FindFirstChild("ROOT_LOC").Value; --String value

for i, v in pairs(C_ROOT:GetChildren()) do --Cannot do this because it is a string
	print(i, v) 
	if (v.ClassName == "RemoteFunction") then 
		ROOT_LINKER = v; 
	end 
end

1 comment

1 answer

I figured it out, so I am posting the solution here for anyone who had a similar problem to mine.

a = {}

for w in string.gmatch("Workspace.Brick", "%P+") do
	a[#a+1] = w;
end

local a_res = game;
for i = 1, #a do
	a_res = a_res[a[i]];	
end
a = a_res;

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