It keeps says this error message or it would say Humanoid is not a valid member of "testDummy"
My testDummy is in a folder in serverStorage called AiFolder
This is called in a different script.
The testDummy has everything a character has
If you need any more information, PLEASE tell me. I have been working on this problem for a good 3 days now. It is starting to get annoying.
local enemy = {}
function enemy.AI(enemyModelName, enemySpawningPlatformName, yOffSet)
-- Detects if the AI is in folder! Printed output if true
-- If the AI is not showing, then there is no created AI in folder
local AiFolder = game.ServerStorage.AiModels
for i, v in pairs(AiFolder:GetChildren()) do
if tostring(enemyModelName) == tostring(v) then
-- Prints if the AI is in folder
print("Found model "..tostring(v))
end
end
-- Detects if the spawning platform is in the spawning folder
-- If not then it would do nothing!
local spawningFolder = game.Workspace.Map.AiSpawningPlatform
local spawningPlatform = spawningFolder[enemySpawningPlatformName]
for i, v in pairs(spawningFolder:GetChildren()) do
if tostring(spawningPlatform) == v.AiSpawningName.Value then
-- Prints if spawning platform is in folder!
print("Spawning platform "..tostring(v).." is in folder!")
end
end
-- Spawns the AI at the spawning Platform
-- The Ai comes from the Folder
local function spawnEnemy()
-- Positions of the spawning platforms
local xPosition = spawningPlatform.Position.X
local yPosition = spawningPlatform.Position.Y
local zPosition = spawningPlatform.Position.Z
local AiSpawnModel = game.ServerStorage.AiModels[tostring(enemyModelName)]:Clone()
AiSpawnModel.Parent = game.Workspace
-- Getting the specific AI
--local AiModel = game.ServerStorage.AiModels[enemyModelName]
--local AiSpawnModel = AiModel:Clone()
--AiSpawnModel.Humanoid.Health = 100
--AiSpawnModel.HumanoidRootPart.Position = Vector3.new(xPosition, yPosition + yOffSet, zPosition)
--AiSpawnModel.Parent = game.Workspace.Map.Enemy[tostring(spawningPlatform.islandType.Value)]
end
spawn(spawnEnemy)
wait(1)
local AiObjectModel = game.Workspace[tostring(enemyModelName)]
-- This function will detect when the enemy is dead
while true do
wait()
AiObjectModel:WaitForChild("Humanoid").Died:Connect(function()
AiObjectModel:Destroy()
spawn(spawnEnemy)
end)
end
end
return enemy

4 comments
The big comments is what I had earlier, I was just seeing if it was something with the :Clone() funciton
do you really have "Humanoid" inside testDummy?
Yes It has everything a character has, I had to double check.
I can see the humanoid inside of testDummy but the WaitForChild() function would not I guess detect it?