I am creating an RPG (RolePlayGame) and have run into a problem.
npc = script.Parent:Clone() function Died() wait(5) npc.Parent = script.Parent.Parent npc:MakeJoints() npc.Enemy.Health = npc.Enemy.MaxHealth script.Parent:Remove() end script.Parent.Enemy.Died:connect(Died)
Sometimes the npc will respawn, sometimes it won't ever respawn again. I get this error message.
16:44:35.337 - Workspace.Weak Bandit..Respawn:5: attempt to index global 'npc3' (a nil value) 16:44:35.339 - Stack Begin 16:44:35.341 - Script 'Workspace.Weak Bandit..Respawn', Line 5 16:44:35.343 - Stack End
Anyone know what is wrong?
Make sure to add a humanoid in the Enemy. The Died event only works in the humanoid.
npc = script.Parent:Clone() function Died() wait(5) npc.Parent = script.Parent.Parent npc:MakeJoints() npc.Enemy.Health = npc.Enemy.MaxHealth script.Parent:Remove() end script.Parent.Enemy.Humanoid.Died:connect(Died) --Here is where I added 'Humanoid'