Weird thing is this used to work, I think. But I have a basic respawn script that is supposed to call a function in a script that does the real respawn but for some reason it is never called (likely due to script being destroyed before it has time to run?)
local robo = script.Parent.Name
local humanoid = script.Parent:FindFirstChildOfClass("Humanoid")
local ourFunctions = require(game:GetService("ServerScriptService"):FindFirstChild("SavingFunctions"))
local DeathSound = script.Parent:WaitForChild("Head"):FindFirstChild("Died")
humanoid.Died:connect(function()
print(robo, "DIED!")
ourFunctions.RespawnEnemyEvent(robo) -- this does the respawning
DeathSound:Play()
-- unequip tool
humanoid:UnequipTools()
if script.Parent:FindFirstChild("FollowAI")then
script.Parent:FindFirstChild("FollowAI").Disabled = true
end
if script.Parent:FindFirstChild("DamageScript") then
script.Parent:FindFirstChild("DamageScript").Disabled = true
end
end)
The print statement is not even running. The respawn works fine when the enemy is killed by the player or another NPC but doesn't when they fall from the map. Does anyone know a work around?

1 comment
Best workaround may be removing the possibility of the enemy falling off the map or have the script be part of ServerScriptService instead of being the child of the enemy model, or wherever you currently have it placed.