How to make npcs respawn after death?

I tried this:



event.OnServerEvent:Connect(function(player)
    
    wait(4)
    
    player:LoadCharacter()
    
    
    for i, v in pairs(game.Workspace:GetChildren()) do
        
        if v:FindFirstChild("Humanoid") and v.Name ~= player.Name then
            if v.Humanoid.Health <= 0  then
                v:MakeJoints()
            end
        end
    end
end)

But it’s not working!

Your script is not working because you are reloading the player instead of the NPCs.
local NPCs = game:GetService(“Workspace”):WaitForChild(“NPCs”) – NPCs folder

local function respawnNPCs()
for _,npc in next,NPCs:GetChildren() do
if npc:FindFirstChild(“Humanoid”) then
if npc.Humanoid.Health <= 0 then
npc:LoadCharacter() – Respawn NPC
end
end
end
end

game.Players.PlayerAdded:Connect(function()
wait(4) – Wait for character to load (NPCs will be loaded too)
respawnNPCs()
end)

Uh no I reloaded the player separately in the same script I load the npcs in but thank you anyways!

Your ‘thank you anyways’ doesn’t change the fact that your solution didn’t work. You should have done more research before trying something so ill-advised - it’s a good thing you asked for help or you would have been even further behind. Maybe next time you should think before you act instead of relying on luck and good manners.

Also Also, Your script didn’t work because LoadCharacter() Only works for non-npcs and people in players service from what I saw sooooo STOP USING CHATGPT and don’t ridicule people like in the OTHER forums you replied in :>

1 Like

i know you are but what am i???

i know you still are but what am i???

This is something that many would Consider very simple and that it shouldn’t require much effort:
There are a Couple of Sources you can look at, and a Video I provided of a Simple Respawn

The way I usually do this is by having a character that I want to spawn in put in Server Storage. Then to actually spawn in a character, I clone the model from server storage, parent them to somewhere under workspace and move their position to the spawn location.

So something like this

local npc = game.ServerStorage.npc

local function spawnCharacter(spawnLocation)
    if spawnLocation:IsA("BasePart") then spawnLocation = spawnLocation.Position end --This just makes it so that you could pass a spawn location part in instead of the position if that's how your code is best set up
    local newChar = npc:Clone()
    newChar:MoveTo(spawnLocation)
    newChar.Parent = game.Workspace
end