The way I said to do it should work, if I am understanding what you want.
If its not too much trouble, can you explain what you are wanting to do (I know you did in the original post, but it seems you made changes and modifications, so just want to be clear on what at this point we are trying to achieve) and I will help you find a working solution.
What are all these events and stuff for? Could you share all your scripts and describe what youâre trying to do?
This thread seems like it might be getting more complicated than it needs to be
Exactly what I was saying, we need to begin and the beginning, with a clear idea of the goal, and just start fresh.
Yes, it is in the workspace.
edit: OHH i just realised i cloned it into the workspace, and the npc is supposed to move to a folder.
wait, it already does thatâŚ
The goal is to spawn the npc every 3-5 seconds on loop so I tested duplicating the npc when it starts walking, it works and it goes into server storage and also to test, 1 sec before itâs destroyed it moves It to the workspace, everything is restored but in post 18 the bug comes in.
spawn 1 in the name means it for dummy 1 and middle means the middle part of the path. its a part in the workspae
Maybe this will help
RespawnMonsterAfterDeath.rbxl (126.7 KB)
The Green Pad will do the initial spawning of the monster.
script.Parent.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and #workspace.Monsters:GetChildren() < 1 then
local monster = game.ServerStorage:WaitForChild("Monster"):Clone()
monster.Parent = workspace.Monsters
end
end)
The red pad will remove the monster.
script.Parent.Touched:Connect(function(part)
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player and workspace:FindFirstChild("Monsters") then
for _,monster in pairs(workspace.Monsters:GetChildren()) do
monster:Destroy()
end
end
end)
The monster spawn inside the Folder called Monsters
And inside the monster, is a ârespawnâ script
Here is the respawn code
local clone = script.Parent:Clone()
local humanoid = script.Parent:WaitForChild("NPC")
humanoid.HealthChanged:Connect(function()
if humanoid.Health <= 0 then
wait(math.random(3,5))
clone.Parent = workspace.Monsters
script.Parent:Destroy()
end
end)
So try that out and see if any of that helps you in any way.
This is perfect! I will give you the results later. I have things to do.