Hello, so i made this module function, which essentially is used for loading maps in the game, however it gives the error in the title at the line “Root.CFrame = Map.FLDR*Spawns[Location].CFrame” , the script is a module script located in a folder in ReplicatedStorage
function Functions:LoadMap(Map, Ambience, Location)
for , Obj in ipairs(Maps_Folder:GetDescendants()) do
Obj.Parent = LoadMaps_Folder
Map.Parent = Maps_Folder
Root.CFrame = Map.FLDR_Spawns[Location].CFrame
Ambience.Playing = true
local function Map_Name(Name_UI)
local TWMN_Info = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local Tween_MapName1 = Tween_Service:Create(Name_UI, TWMN_Info, {TextTransparency = 0})
local Tween_MapName2 = Tween_Service:Create(Name_UI, TWMN_Info, {TextTransparency = 1})
Name_UI.Visible = true
Tween_MapName1:Play()
task.wait(3.5)
Tween_MapName2:Play()
task.wait(0.75)
Name_UI.Visible = false
end
if string.match(Map.Name, "Crossroads") then
Map_Name(MapNames_Folder.Name_Crossroads)
elseif string.match(Map.Name, "RobloxHQ") then
Map_Name(MapNames_Folder.Name_RobloxHQ)
end
end
end
Invalid argument #2 (type expected, got type) usually occurs when you use invalid types on an operation.
in the suspected line:
Root.CFrame = Map.FLDR_Spawns[Location].CFrame
you are using indexing operators [] on a folder.
In luau, indexing using instances is only allowed on tables as a key value pair.
when using indexing on an instance (folder) you need to pass a string.
so if you could reveal what location is, then I can help you.
But currently all I can suggest is adding .Name to location if it is a model.
if you could reveal the types of the arguments and their purpose that would help in identifying the issue.
the other person suggested tostring(), but if location is a model or anything else, like a table, that won’t work.
for instances, use the .Name property instead.