I’m trying to write an NPC Respawner that automatically respawns an NPC once it dies. However, for some reason, it only works once. I honestly have no idea what’s causing this. Neither the Script Editor nor Output is showing errors. Any help is appreciated. If you need more info/screenshots, I’d be happy to try and get them.
Expected Behavior: Once the NPC Practice Dummy dies, it is deleted and replaced immediately. The replacement takes the place of the original.
Current Behavior: If the NPC dies, it’ll be deleted and replaced. However, if the replacement dies, nothing happens.
Script:
local Dummy = workspace["Practice Dummies"]["Practice Dummy One"]
local Variable
local function Respawn()
print("Died.")
Dummy:Remove()
local Respawned = script["Practice Dummy One"]:Clone()
Respawned.Torso.Position = Vector3.new(-33.5, 4.5, -49.5)
Respawned.Parent = workspace["Practice Dummies"]
Dummy = Respawned
Variable:Disconnect()
print(Dummy.Humanoid.Health)
print(Dummy.Parent)
end
Variable = Dummy.Humanoid.Died:Connect(Respawn)