Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1.  
  2. -- Explained
  3. local dir_string = 'Pan.Tilt.Mesh'
  4. local dir_tab = {}
  5. for x in dir_string:gmatch('[^.]+') do -- ^. meaning not . and + meaning until interupted by .
  6.     table.insert(dir_tab) -- add the string to the table
  7. end
  8. -- dir_tab is now {'Pan','Tilt','Mesh'}
  9. -- it essentially does the opposite as table.concat(dir_tab, '.')
  10.  
  11. local d = workspaceb -- Set the starting location
  12. for k, v in pairs({'Pan','Tilt','Mesh'}) -- The gmatch pattern essentially seperates it into the table specified in pairs()
  13.     d = d[v] -- set current location to the child with the name v of current location
  14. end
  15. print(d:GetFullName()) -- > game.Workspace.Pan.Tilt.Mesh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement