Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 04 Jul 2014 04:30 PM |
I have this script inside of an NPC;
script.Parent.Humanoid.Died:connect(function(res) local modl = game.ServerStorage.Hollow local times = math.random(1,10) if (script.Parent.Humanoid.Health) == 0 then wait(times) vr = modl:Clone() vr.Parent = game.Workspace vr:MakeJoints()
vr:MoveTo(script.Parent.Head.Position)
script.Parent:Destroy() end end)
Whenever the NPC dies it is supposed to respawn between 1 to 10 seconds. But the problem is it works one time in test mode, and stops working after the second time that NPC is killed. And it doesn't work at all in-game. Help? What to do? |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2014 04:44 PM |
function respawn () local modl = game.ServerStorage.Hollow local times = math.random(1,10) local health = script.Parent.Humanoid.Health if health == 0 then wait (times) vr = modl:Clone() vr.Parent = game.Workspace vr:MakeJoints() vr:MoveTo(script.Parent.Head.Position end end
local NPC = script.Parent.Humanoid Humanoid.Died:connect(respawn)
I hate the LGBT. Those laser guided battle tanks are just too damn powerful. |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 04 Jul 2014 06:18 PM |
| This didn't change anything. All that was changed was the anonymous function. |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 04 Jul 2014 06:51 PM |
script.Parent.Humanoid.Died:connect(function(res) local modl = game.ServerStorage.Hollow local times = math.random(1,10) --if (script.Parent.Humanoid.Health) == 0 then--wth do you have this wait(times) vr = modl:Clone() vr.Parent = game.Workspace vr:MakeJoints()
vr:MoveTo(script.Parent.Head.Position)
script.Parent:Destroy() --end end) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 04 Jul 2014 06:59 PM |
| So that a new NPC respawns when one dies. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 04 Jul 2014 07:07 PM |
U already have the .Died event -_- Don't do that, because sometimes health can go below 0 I believe. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2014 07:13 PM |
local modl = game.ServerStorage.Hollow
function respawn() local vr = modl:Clone()
vr.Died:connect(function() local times = math.random(1,10) wait(times) vr:Destroy() return respawn() end)
vr.Parent = game.Workspace vr:MakeJoints() vr:MoveTo(Vector3.new(0,0,0)) --Change this to a position
end
script.Parent.Humanoid.Died:connect(function() local times = math.random(1,10) wait(times) script.Parent:Destroy() respawn() end)
--Tell me if this works, it's not pretty, but it's going off of your original script
|
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 04 Jul 2014 07:17 PM |
fire.. a model cannot die...
local vr = modl:Clone()
vr.Died:connect(function()
and I never see a definition of modl |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2014 07:20 PM |
| First line is 'local modl = ...' , and change vr.Died to vr.Humanoid.Died, I typed that kind of fast. |
|
|
| Report Abuse |
|
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 05 Jul 2014 11:32 AM |
Sorry but it is not doing anything at all, I've edited it to this.
local modl = game.ServerStorage.Hollow
function respawn() local vr = modl:Clone()
vr.Humanoid.Died:connect(function() local times = math.random(1,10) wait(times) vr:Destroy() return respawn() end)
vr.Parent = game.Workspace vr:MakeJoints() vr:MoveTo(game.Workspace.PartSpawn.Position)
end
script.Parent.Humanoid.Died:connect(function() local times = math.random(1,10) wait(times) script.Parent:Destroy() respawn() end)
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
|
| 05 Jul 2014 12:03 PM |
| Is hollow the same thing as script.Parent? Or after script.Parent dies it's replaced with an entirely different model? |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 05 Jul 2014 12:06 PM |
| after script.Parent dies it's replaced with an entirely different model but with the same name "hollow" |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2014 12:09 PM |
| I meant to say the model is different in terms of instances, it doesn't look exactly like the original model and it doesn't have the same scripts or hierarchy? |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 05 Jul 2014 12:10 PM |
| Oh, it does look exactly like the other model, and it has the same scripts inside of it. See, when the current NPC in workspace dies, the same one from ServerStorage is supposed to be cloned into workspace. |
|
|
| Report Abuse |
|
|
|
| 05 Jul 2014 12:14 PM |
Okay, put this inside the original model:
local figure = script.Parent:clone()
script.Parent.Died:connect(function() local figure2 = figure:clone() figure2.Parent = script.Parent.Parent figure2:MakeJoints() script.Parent:Destroy() end)
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 05 Jul 2014 12:21 PM |
| Thank you, it works! Would you happen to know where I could implement a wait time before they respawn? |
|
|
| Report Abuse |
|
|