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

Why is my Regeneration script not working?

Asked by 9 years ago

I have changed allot of things in the script, but it is still not working, there is no error Output so I don't know what the problem is, but, the problem is that it is not respawning an NPC, and when it does, the player just dies, or falls through the baseplate, so it repeatedly loops over and over again, here is the script;

repeat wait() until script and script.Parent and script.Parent:FindFirstChild("Zombie")
print("Respawned")
wait(1)
repeat wait(.2)
if script.Parent.Zombie.Health <= 0 then
print("Respawning")
local Respawn = script.Parent:Clone()
Respawn.Parent = game.Workspace
Respawn:MakeJoints()
script.Parent:Destroy()
end
until nil

2 answers

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

The problem is that when you're cloning it, you're cloning it when it's already dead. Set the health back to 100.

repeat wait() until script and script.Parent and script.Parent:FindFirstChild("Zombie")
local Respawn = script.Parent:Clone()
print("Respawned")
wait(1)
repeat wait(.2)
if script.Parent.Zombie.Health <= 0 then
print("Respawning")
Respawn.Parent = game.Workspace
Respawn:MakeJoints()
script.Parent:Destroy()
end
until nil

This should work.

0
Lol, can't believe I didn't see that, Thanks man! :) TheeDeathCaster 2368 — 9y
0
Haha, no prob. Glad I could help :) dyler3 1510 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

Make sure your NPC is a Humanoid not a Zombie and clone it and make sure it's in workspace, for the other one you can delete it.

0
If I do that, then I'd have to change the sword to affect the object 'Humanoid', and doing that will allow players to kill each other except the NPCs, because, all Player's users Characters Humanoid name is 'Humanoid'. TheeDeathCaster 2368 — 9y

Answer this question