I have an issue with this code
local CurrentUnit = nil
local Units = require(game.ServerStorage.ModuleScript)
local function deepCopy(original)
local mt = getmetatable(original)
local copy = {}
for k, v in pairs(original) do
if type(v) == "table" then
v = deepCopy(v)
end
copy[k] = v
end
if mt ~= nil then
print(mt)
setmetatable(mt)
end
return copy
end
script.Parent.MouseButton1Click:Connect(function()
CurrentUnit = deepCopy(Units.Defaults.MeleeCop)
CurrentUnit.Model = CurrentUnit.Model:Clone()
CurrentUnit:Cast()
end)
right before the error happens, mt is listed as the following:
17:58:00.261 ▼ {
["Attack"] = "function",
["Cast"] = "function",
["CheckForward"] = "function",
["Defaults"] = ▶ {...},
["InPlay"] = {},
["MoveForward"] = "function",
["__index"] = ▶ {...},
["new"] = "function"
} - Server - Script:13
