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

Respawn script for my enemy npcs doesn't work as I would like it to?

Asked by 8 years ago

So, I have an enemy setup wherei t moves back and forth, and if you jump on it's head, it dies. I have a respawn script so after 5 seconds of it being dead, it respawns, however, when it respawns the scripts I have set for it fail, for example, when I jump on its head it doesn't die, and it doesn't move back and forth like it used too.

-- Respawn Script (Outside of NPC Model)
local clone = workspace.Goomba:Clone()

workspace.Goomba.Humanoid.Died:connect(function()
wait(5)
workspace.Goomba:Destroy()
clone.Parent = workspace
local clone = workspace.Goomba:Clone()


end)
--Jump on head = die script (inside model)
function OnTouched()
    local h = game.Workspace.Goomba:findFirstChild("Humanoid")
    if h ~= nil then
        h.Health = 0
    end
end

script.Parent.Touched:connect(OnTouched)

--walk script for npc (outside of its model)
while true do
script.Parent.Goomba.Humanoid:MoveTo(Vector3.new(0.776, -0, -20.173))
wait(4)
script.Parent.Goomba.Humanoid:MoveTo(Vector3.new(0.776, -0, -33.173))
wait(4)
end

This is kinda urgent! Any help appreciated

Answer this question