Could someone please explain how the variable current is concatenating current[v]?
I thought concatenation required the … operator?
current will be a reference to game.Workspace.Baseplate once the for loop has finished iterating.
local dir="Workspace.Baseplate"
local segments=dir:split(".")
local current=game --location to search
for i,v in pairs(segments) do
current=current[v]
end
print(typeof(current)) --"Instance"
It’s not concatenating. It starts at game, then on the first iteration it indexes game with "Workspace", and now current will refer to game.Workspace, and then on the last iteration it indexes current, which is now the workspace, with "Baseplate", which finally means it refers to the baseplate.
I wouldn’t really say roblox has a directory like you’d see in like windows more over its like a big table. You’d have to do like what incapaz said do like game[“Workspace”][“Baseplate”]