So I have a block called “Spawner” that I want my enemy NPC to respawn in after the player kills it and it worked fine at first, but for some reason whenever I move the ring around with the spawner the NPC will always respawn at the old location in studio. I’ve tried setting a new location with the NPC dies, but that didn’t work.
Killing NPC Before Move: https://gyazo.com/ae051617d8ec7ff4fad057598ab134ec
Killing NPC After Move: https://gyazo.com/c1946cc9e09ac4ad185c975f9f981cf9
Spawner Location: https://gyazo.com/bd52dcb93ce3e21a358c4ae95a370a6b
Respawn Code:
local humanoid = script.Parent:WaitForChild("Humanoid")
function respawnNPC()
local NPCBackup = game.ServerStorage["Scarlet \"Rainbow\" Underkill"]:Clone()
script.Parent:Destroy()
NPCBackup.Parent = workspace.NormalFightingRingScarlet.Enemies
-- Check if the respawn location exists before using it
local respawnLocation = script.Parent.Parent.Parent.Spawner
if respawnLocation then
NPCBackup.HumanoidRootPart.CFrame = respawnLocation.CFrame + Vector3.new(0, 5, 0)
end
end
while wait(3) do
if humanoid.Health <= 0 then
respawnNPC()
end
end