Hello all, I am creating an RPG game, and have been coming into difficulty when making my "Monster" or enemy NPC's!

So, my only issue I've run into is this "respawn" script, where, it detects when the humanoids health is less than 1, and then respawns them via :clone and :MakeJoints()

The code respawns the NPC correctly, and at the point of placement in workspace, BUT, my trouble is I am trying to make him respawn after a certain time period, and was wondering where/how I would go about coding this inside my script listed below!

Here's my script, any and all help is appreciated!

name="Humanoid"

robo=script.Parent:clone()

while true do
	wait(5)
	if script.Parent.Humanoid.Health<1 then
		robot=robo:clone()
		robot.Parent=script.Parent.Parent
		robot:makeJoints()
		script.Parent:remove()
                wait(5)
	end
end

6 comments

0

How do you mean respawn after a certain time period? Also, you can add a wait at the start to make it take longer to do the other code if thats what you wanted,  BTW I am prob not gonna respond to and responses in the past few hours, thanks!.

0

I mean, after the "remove()" function, I'd like for it to wait a certain amount of time before the clone and essentially respawning the NPC.

0

Just add a wait()?

0

Did that, didn't work. Just broke the script.

0

where did you add the wait

0

At the end