Help with respawning system

working on this but. one part works other does not here is the script

game.ReplicatedStorage.SphereShooter.OnServerEvent:Connect(function(plr,noob,Spheredmg)
	wait(0.6)
	
	
		noob.Humanoid.Health -= Spheredmg
		
	for i , v in pairs(game.Workspace.Noobs:GetChildren()) do
		if v:FindFirstChild("Humanoid") then
				if v.Humanoid.Health == 0 then
					while wait(0.1) do
						if v.Name == "Noob" then
							local noobpos = v.Torso.Position
						plr.leaderstats.Coins.Value += 10
						plr.ExpFolder.Expierience.Value += 5
						local clonednoob = game.ReplicatedStorage.Noob:Clone()
						clonednoob.HumanoidRootPart.Position = noobpos
						clonednoob.Parent = workspace.Noobs
						v:Destroy()
					elseif v.Name == "ZombieNoob" then
							local noobpos2 = v.Torso.Position
						plr.leaderstats.Coins.Value += 20
						plr.ExpFolder.Expierience.Value += 10
						local clonednoob = game.ReplicatedStorage.ZombieNoob:Clone()
						clonednoob.HumanoidRootPart.Position = noobpos2
						clonednoob.Parent = workspace.Noobs
						v:Destroy()
						end
						
						
				end
			end
		end
	end
end)

here is what it does in game

1 Like

your “for loop” goes through the “Noobs” table, did you put both the Noobs and Zombie Noobs in that same table or are they placed in different ones?, and also are there any errors visible in the output

-it would help if you sent a picture of the workspace so that we can see how you (placed/sorted) everything.

Ohh yea sorry they are in the same “Noobs” folder and no errors that is why I checked there name bc they in same folder but the problem is that they respawn its just not in the same position and im not sure why cuz the one above it works but not the zombie one but its the same script so idk

1 Like

okay so of the zombies do respawn but not in the right position where do they exactly respawn? and try to put a print in the “Zombie Noob condition” to see if the problem is inside or is the condition itself

Yea watch the video they all spawn in the exact same place

You don’t understand I see in the video that the normal noobs do respawn everytime at the same place and that’s normal because in your script the “clonednoob” position is set to “noobpos = v.Torso.Position” so the same as the old noob’s position (the one that died), and the green noobs (zombie noobs) do not respawn at all, so what must be causing that is a problem with this part of your script:

elseif v.Name == "ZombieNoob" then
							local noobpos2 = v.Torso.Position
						plr.leaderstats.Coins.Value += 20
						plr.ExpFolder.Expierience.Value += 10
						local clonednoob = game.ReplicatedStorage.ZombieNoob:Clone()
						clonednoob.HumanoidRootPart.Position = noobpos2
						clonednoob.Parent = workspace.Noobs
						v:Destroy()
						end

or a mistake you made in the workspace (you placed the zombie noobs or something else in the wrong place/folder or named something the wrong name)

-check everything even the HumanoidRootParts and the ZombieNoob that is in the ReplicatedStorage

Check the console for errors while testing in studio, that’ll give us a better idea at what the problem might be.

I’ve alr said like a mil times no errors

You said once, but you didn’t claim that you tested while in Roblox studio.

Hard to tell what exactly is wrong, need more info

Ok watch the zombie noobs they respawn but not in the right position they all just stack up in one spot watch the video again