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

Respawning Mob Script wont work anymore?

Asked by 6 years ago
Edited 6 years ago

ok so I have tried literally everything!! To fix this script but it wont work whatsoever.

My goal is to make this zombie model respawn after 1 second of its death.

so far this is what I have

local zombie = game.Workspace.Zombie
local clone = zombie:Clone()


if zombie.Humanoid.Died then zombie.Humanoid.Died:connect(function()
wait(2)
zombie:Destroy()
clone.Parent = game.Workspace
end)
end

Now it works, but only 1 time. After its first death it doesnt respawn after it dies anymore. :(

Please someone help me. I just came back to coding after what seems like forever.

0
:connect() is deprecated sadly, instead, use :Connect() hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Put this in the actual zombie model. Died is a signal, not something you can check like you tried. You're also going to want the script to be in the zombie because you don't want to have to wire it to the died event each time you clone a new zombie. Also, if the script did end up working, it'll only connect to the died event once, after that it wouldn't work for new zombies. You would also probably get an error on your zombie variable in an online server, because you didn't use WaitForChild(). Scripts tend to load before objects (online) and error if you don't wait for those objects to load first.

local zombie = script.Parent
local humanoid = zombie:WaitForChild("Humanoid")
local clone = zombie:Clone()

humanoid.Died:Connect(function()
    wait(2)
    clone.Parent = workspace
    zombie:Destroy()
end)
0
May i ask what i did wrong? iizWishzii 21 — 6y
0
instead of died you can do humanoid.Health MrDragonTaker 0 — 6y
Ad

Answer this question