How to get Name from the argument/parameter instead of literally the Folder Name?

local function funcname(Name)
local model = script.Parent.Enemies.Models.Name
end

funcname(Dummy)

Models is a folder fyi. Inside that folder theres a model (r15 rig) called “Dummy”.
I want local model assigned to that Dummy rig.
I tried changing Name → name, but it still prints out the folder name.

Use brackets. When you do .Name you’re looking for a field called Name.

local model = script.Parent.Enemies.Models[Name]

When you use brackets you’re looking for a field with the value of the variable Name.

1 Like

Thanks, do you also know how to ‘redirect’ a table, like table[1] containing “Name”, to the argument?

local function funcname(Name)
local a = {Name}
local model = game.ReplicatedStorage.Modules.Enemies.Models["a"..1]
print(model)
end

funcname("Dummy")

It prints out a1 is not a valid member of folder (Models).

–EDIT-- Nvm, figured it out.