generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: halp pl0x

Previous Thread :: Next Thread 
wafles26122 is not online. wafles26122
Joined: 14 Jun 2010
Total Posts: 958
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
wafles26122 is not online. wafles26122
Joined: 14 Jun 2010
Total Posts: 958
04 Jun 2012 08:52 PM
ignore the `--Y DIS REMOVE ALL AFTER 1 DIES`

o.o
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
04 Jun 2012 08:56 PM
Why create a coroutine EACH TIME instead of only having one...?
Report Abuse
wafles26122 is not online. wafles26122
Joined: 14 Jun 2010
Total Posts: 958
04 Jun 2012 08:57 PM
There is only 1 coroutine.....those are events.....
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
04 Jun 2012 09:00 PM
Nope, every time you spawn a new zombie another coroutine is created.
Report Abuse
DragonWarlord101 is not online. DragonWarlord101
Joined: 26 Oct 2008
Total Posts: 363
04 Jun 2012 09:03 PM
Would you fix it for us, please?
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
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
DragonWarlord101 is not online. DragonWarlord101
Joined: 26 Oct 2008
Total Posts: 363
04 Jun 2012 09:11 PM
It worked, thanks, ElectricAxel!!
Report Abuse
wafles26122 is not online. wafles26122
Joined: 14 Jun 2010
Total Posts: 958
05 Jun 2012 08:30 AM
oh....I didn't think about doing that. :P
Report Abuse
wafles26122 is not online. wafles26122
Joined: 14 Jun 2010
Total Posts: 958
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
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
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
DragonWarlord101 is not online. DragonWarlord101
Joined: 26 Oct 2008
Total Posts: 363
05 Jun 2012 11:55 PM
O.o that never occurred to us.. Thanks!!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image