Respawn Script Needed For Upcoming Project

What Do I Want To Achieve?

  1. What I want to achieve is becoming a great Roblox Developer, and to become a scripter so my games can come to life.

What Issues Do I Have?

  1. Some Issues that I have is that I have be in need of a new game and I’m trying to make a Respawn Script for one of these things…
    So for this image I wanna make a script so that it can respawn itself. For this image I want the Noobs to be on the block and respawn there, so that when they do it can be there starting point for the game
    But this is half of the development progress I have so far…

What Solutions Have I Tried So Far?

  1. I have tried watching Youtube videos for the script but all the scripts where not working because they where outdated.

I need the correct respawn script for my Rig Characters, if you happen to be a Programmer/Scripter please tell me.

Thank you for reading, have a great day :smiley:

1 Like

Hang on, I don’t get your post, do you want the block to be respawned or the noob? Please explain more, sorry

2 Likes

I think he wants the noob to respawn on top of the brick, not sure.

1 Like

Hey your post is still vague though you used correct format :confused:

2 Likes

Yeah I dont get what your trying to say, you want the noob to start on the block, will it be killed or something?

2 Likes

Please explain REALLY DETAILLED what it is you’d like to do with that script.

You want the noob to respawn on the brick? Then I would just make 2 teams, make 2 spawns, set the spawns each to one of the teams, and team the noob team 1 (or 2). Then he respawns on the spawn you set to the team the noob is in.

Let me know if you need more help

3 Likes

Do you want the “noob” or “player” to respawn in the brick?

2 Likes

Sorry if my post is unexplained, but i want the noob to respawn .

1 Like

I want the noob to respawn of the brick, sorry if my post is unexplained.

1 Like

Correct, see as a animator/builder as myself im not that very good at programming.

1 Like

In that case, I have thrown together some code.

Insert a Script inside the NPC (noob), then copy paste the code below into the Script you just inserted.
Edit the RESPAWN_BRICK and RESPAWN_TIME variables.
If you need help with editing those variables just reply.
Make sure the NPC has a HumanoidRootPart and a Humanoid.

NPC Code
local humanoid = model:FindFirstChildOfClass('Humanoid')
local clone = model:Clone()

local RESPAWN_BRICK = workspace.RespawnBrick -- where the NPC would respawn
local RESPAWN_TIME = 6 -- number of seconds to respawn after the NPC has died

humanoid.Died:connect(function()
	wait(RESPAWN_TIME)
	
	model:Destroy()
	
	clone.Parent = workspace
	clone.HumanoidRootPart.CFrame = RESPAWN_BRICK.CFrame * CFrame.new(0, 3, 0)
end)

I have tested this and it works with no problems.

2 Likes

Thanks for the help i want this to be perfect I appricate it :slight_smile:

1 Like

Yes so I have just did what you said and i think im doing something wrong, so the script below the one i just inserted was a script for chasing the player until it dies.

– local larm = script.Parent:FindFirstChild(“HumanoidRootPart”)
local rarm = script.Parent:FindFirstChild(“HumanoidRootPart”)

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 10000
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == “Model”) and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild(“HumanoidRootPart”)
human = temp2:findFirstChild(“Humanoid”)
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end

while true do
wait(1)
local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
if target ~= nil then
script.Parent.Zombie:MoveTo(target.Position, target)
end

end

And I have placed it in the respawn script below it and it didn’t respawn, if you have some time may you please help me with it?

1 Like

Try inserting a different script than that one. Don’t put the respawn code into the chase script.

2 Likes

I have, but watch this video, sorry if its a bit laggy but I have edited the respawn time variables and it still hasent respawned, look closely…

1 Like

That script has some issues. I used to use it before I knew how to use magnitude.

I made this one and it is a lot simpler and it works fine.


function findNearestTorso()
	main = math.huge
	for i,v in pairs(game.Players:GetChildren()) do
		if v.Character then
			if (v.Character.HumanoidRootPart.Position - script.Parent.Torso.Position).Magnitude < main then
				if v.Character.Humanoid.Health > 0 then
				main = (v.Character.HumanoidRootPart.Position - script.Parent.Torso.Position).Magnitude 
				torso = v.Character.HumanoidRootPart
				end 
			end
		end
	end
	return torso
end 

while wait() do

	local target = findNearestTorso()
	if target ~= nil then
		script.Parent.Zombie:MoveTo(target.Position, target)
	end 
end 

Also put it in a different script than the respawn one.

2 Likes

Oh Sorry @sozzly there was a error that i was trying to upload the file.

1 Like

It hasn’t respawned, I might be doing something wrong for it to not respawn

1 Like

The code sozzly sent should work.
Make sure you replace “model” with the path.

2 Likes