Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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
0
It needs to be a real player, not an NPC! KetchupRBLX 0 — 6y
0
a real player respawns when it is killed JakePlays_TV 97 — 6y
0
Yeah KetchupRBLX 0 — 6y
0
so then where is the issue?? JakePlays_TV 97 — 6y
Ad

Answer this question