Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

When I attack the humanoid, then the humanoid's health is 0, it won't respawn! What should I do?

I'm testing outside ROBLOX Studio, it won't respawn once I attacked the humanoid. (Not a dummy, a real player)

Do I have to put p.Parent.Humanoid.Health == 0 ? I didn't use LocalScript, I used the normal script inside the tool.

local CanDamagePlayers = true
local damage = 3


script.Parent.Top.Touched:connect(function(p)
	if p.Parent:FindFirstChild("Humanoid") and CanDamagePlayers == true and p.Parent.Humanoid.Health > 0 then
		local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
		
		p.Parent.Humanoid:TakeDamage(damage)
		script.Parent.Sound:Play()
		plr.leaderstats.Pins.Value = plr.leaderstats.Pins.Value + 4
		CanDamagePlayers = false
		wait(1)
		CanDamagePlayers = true
	end
end)

1 answer

To make an npc respawn do this

while true do
local npc = game.Workspace.Zombie -- The Zombie can be changed to the name of ur npc
local respawnPos = (0,0,0) --Obviously change this
if npc.Health == 0 then
npc.Position = Vector3.new(respawnPos)
end
end

4 comments

0

It needs to be a real player, not an NPC!

0

a real player respawns when it is killed

0

Yeah

0

so then where is the issue??

This discussion is preserved as it was. New answers, comments, and votes are closed.