|
| 04 Jun 2012 08:51 PM |
Ok so me and my friend DragonWarlord101 are trying to make a script that spawns dummies at my that try to kill him and he tries to shoot them all and kill them....We have many problems though.....just 1 is that they stop following him the 2nd time you say the command to spawn them. We made the clone 'nub' ahead of time so don't worry about that......
c = game.Lighting.nub nubs = {} function chatted(msg) if string.find(msg, "cp/") ~= nil then start, ed = string.find(msg, "cp/") if string.sub(msg, 4) ~= "" then num = tonumber(string.sub(msg, 4)) for i=1, num do cc = c:Clone() cc.Parent = Workspace cc.Humanoid.MaxHealth = 100 cc.Humanoid.Health = 100 table.insert(nubs, cc) cc:MoveTo(Workspace.wafles26122.Torso.Position + Vector3.new(math.random(-15, 15), 1, math.random(-15, 15))) cc.Torso.Touched:connect(function(part) if part.Parent:findFirstChild("Humanoid") ~= nil and part.Parent.Name == "DragonWarlord101" then part.Parent.Humanoid:TakeDamage(math.random(1, 15)) end end) coroutine.resume(coroutine.create(function() while true do for x=1, #nubs do nubs[x].Humanoid:MoveTo(Workspace.DragonWarlord101.Torso.Position, Workspace.DragonWarlord101.Torso) if nubs[x].Humanoid.Sit == true then wait(1.5) nubs[x].Humanoid.Sit = false end nubs[x].Humanoid.Died:connect(function() wait(0.25) nubs[x]:Remove() table.remove(nubs, x) --Y DIS REMOVE ALL AFTER 1 DIES end) end wait() end end)) end end end end game.Players.wafles26122.Chatted:connect(chatted)
|
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:52 PM |
ignore the `--Y DIS REMOVE ALL AFTER 1 DIES`
o.o |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:56 PM |
| Why create a coroutine EACH TIME instead of only having one...? |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 08:57 PM |
| There is only 1 coroutine.....those are events..... |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 09:00 PM |
| Nope, every time you spawn a new zombie another coroutine is created. |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 09:03 PM |
| Would you fix it for us, please? |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 09:09 PM |
I have a certain doubt about something but I'll see if thats the problem later, try this first.
c = game.Lighting.nub nubs = {} function chatted(msg) if string.find(msg, "cp/") ~= nil then start, ed = string.find(msg, "cp/") if string.sub(msg, 4) ~= "" then num = tonumber(string.sub(msg, 4)) for i=1, num do cc = c:Clone() cc.Parent = Workspace cc.Humanoid.MaxHealth = 100 cc.Humanoid.Health = 100 table.insert(nubs, cc) cc:MoveTo(Workspace.wafles26122.Torso.Position + Vector3.new(math.random(-15, 15), 1, math.random(-15, 15))) cc.Torso.Touched:connect(function(part) if part.Parent:findFirstChild("Humanoid") ~= nil and part.Parent.Name == "DragonWarlord101" then part.Parent.Humanoid:TakeDamage(math.random(1, 15)) end end) end end end end game.Players.wafles26122.Chatted:connect(chatted)
coroutine.resume(coroutine.create(function() while true do repeat wait(.5) until #nubs > 0 for x=1, #nubs do nubs[x].Humanoid:MoveTo(Workspace.DragonWarlord101.Torso.Position, Workspace.DragonWarlord101.Torso) if nubs[x].Humanoid.Sit == true then wait(1.5) nubs[x].Humanoid.Sit = false end nubs[x].Humanoid.Died:connect(function() wait(0.25) nubs[n]:Remove() table.remove(nubs, n) --Y DIS REMOVE ALL AFTER 1 DIES end) end wait() end end)) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2012 09:11 PM |
| It worked, thanks, ElectricAxel!! |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2012 08:30 AM |
| oh....I didn't think about doing that. :P |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2012 08:29 PM |
ok new problem is it only removes half of them every time I say clean/
p = game.Lighting.nub nubs = {} function chatted(msg) if string.sub(msg, 1, 6) == "clean/" then for xx=1, #nubs do nubs[xx]:Destroy() table.remove(nubs, xx) wait() end end if string.find(msg, "sn;") ~= nil then start, ed = string.find(msg, "sn;") if string.sub(msg, 4) ~= "" then num = tonumber(string.sub(msg, 4)) for i=1, num do cc = p:Clone() cc.Parent = Workspace cc.Humanoid.MaxHealth = 100 cc.Humanoid.Health = 100 table.insert(nubs, cc) cc:MoveTo(Workspace.wafles26122.Torso.Position + Vector3.new(math.random(-15, 15), 1, math.random(-15, 15))) cc.Torso.Touched:connect(function(part) if part.Parent:findFirstChild("Humanoid") ~= nil and part.Parent.Name == "DragonWarlord101" then part.Parent.Humanoid:TakeDamage(math.random(1, 15)) end end) end end end end game.Players.wafles26122.Chatted:connect(chatted) coroutine.resume(coroutine.create(function() while true do repeat wait(.5) until #nubs > 0 for x=1, #nubs do nubs[x].Humanoid:MoveTo(Workspace.DragonWarlord101.Torso.Position, Workspace.DragonWarlord101.Torso) if nubs[x].Humanoid.Sit == true then wait(1.5) nubs[x].Humanoid.Sit = false end end wait() end end)) |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2012 08:58 PM |
Simple fix:
p = game.Lighting.nub nubs = {} function chatted(msg) if string.sub(msg, 1, 6) == "clean/" then for xx=1, #nubs do nubs[xx]:Destroy() wait() end nubs = {} end if string.find(msg, "sn;") ~= nil then start, ed = string.find(msg, "sn;") if string.sub(msg, 4) ~= "" then num = tonumber(string.sub(msg, 4)) for i=1, num do cc = p:Clone() cc.Parent = Workspace cc.Humanoid.MaxHealth = 100 cc.Humanoid.Health = 100 table.insert(nubs, cc) cc:MoveTo(Workspace.wafles26122.Torso.Position + Vector3.new(math.random(-15, 15), 1, math.random(-15, 15))) cc.Torso.Touched:connect(function(part) if part.Parent:findFirstChild("Humanoid") ~= nil and part.Parent.Name == "DragonWarlord101" then part.Parent.Humanoid:TakeDamage(math.random(1, 15)) end end) end end end end game.Players.wafles26122.Chatted:connect(chatted) coroutine.resume(coroutine.create(function() while true do repeat wait(.5) until #nubs > 0 for x=1, #nubs do nubs[x].Humanoid:MoveTo(Workspace.DragonWarlord101.Torso.Position, Workspace.DragonWarlord101.Torso) if nubs[x].Humanoid.Sit == true then wait(1.5) nubs[x].Humanoid.Sit = false end end wait() end end)) |
|
|
| Report Abuse |
|
|
|
| 05 Jun 2012 11:55 PM |
| O.o that never occurred to us.. Thanks!! |
|
|
| Report Abuse |
|
|