hello, my friend has been encountering a problem with a script he has been working on.
Here is the script.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptStorage = game:GetService("ServerScriptService")
return function (context, text, number)
local Enemy = require(ServerScriptStorage.Main.Mob)
local EnemyFolder = ReplicatedStorage:FindFirstChild("Mobs")
local map = workspace.Map
local findfirstChild = function(inst, str:string)
if typeof(str) ~= "string" or typeof(inst) ~= "Instance" then return end
str = str:lower()
for Index, Object in ipairs(inst:GetChildren()) do
local ObjectName = Object.Name:lower()
if ObjectName == str or string.find(ObjectName, str) then return Object end
end
end
local childFound = findfirstChild(EnemyFolder, text)
Enemy:Spawn(childFound.Name, number, map)
end
he has been encountering
invalid argument #2 (string expected, got table)
on
if ObjectName == str or string.find(ObjectName, str) then return Object end
both ObjectName and str are strings and are not tables, my mind has been melted from trying to fix this. what seems to be the problem?