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: Debug this, please.

Previous Thread :: Next Thread 
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
12 Dec 2012 06:23 AM
function DeathMatch()
_G.Message("Fight to the death!")
count = 0
for i = 1, #p do
if p[i].Character:FindFirstChild("Playing") then
count = count + 1
end
end
end

repeat DeathMatch() until count <= 1

~SamuelKingx
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
12 Dec 2012 06:33 AM
Eeeee, output? What's the error?
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
12 Dec 2012 08:11 AM
Did you ever define table 'p'?
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
12 Dec 2012 09:55 PM
Yes, p = game.Players:GetChildren()
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
12 Dec 2012 09:56 PM
For some reason, when it gets to this part of the script, it randomly freezes and shows no ouput whatsoever.
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
12 Dec 2012 09:58 PM
Because you never RESET count, so it keeps adding count+1 for every Player, every time You loop it.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
12 Dec 2012 09:59 PM


    function DeathMatch()
    _G.Message("Fight to the death!")
    local count = 0
      for i, v in pairs(p) do
        if p[i].Character:FindFirstChild("Playing") then
          count = count + 1
        end
      end
    end
    
    repeat DeathMatch() and wait() until count <= 1

Maybe? Do you determine if people are playing by checking Playing's value, or it's existence?

¤ † KMXD† ¤
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
13 Dec 2012 03:43 PM
Knight, wouldn't it error since count is local to the Function only?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
13 Dec 2012 03:45 PM
Remove local and give it a try.
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
13 Dec 2012 03:48 PM
Either
a) p is undefined
b) FindFirstChild returned 'false'
c) _G.Message is nil
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
13 Dec 2012 03:48 PM
count = 0
while count > 0 do
wait()
_G.Message("Fight to the death!")
for i = 1, #p do
if p[i].Character:FindFirstChild("Playing") then
count = count + 1
end
end
if count < 1 then break end
end
print("ALL PLAYERS DIED")

-- Try that and see.

Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
13 Dec 2012 03:49 PM
wait nvm...
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
13 Dec 2012 03:52 PM
Actually, you may need a 'wait' there. If the three things I listed check out, then I bet you a 'wait' will fix it.

    function DeathMatch()
    _G.Message("Fight to the death!")
    count = 0
    for i = 1, #p do
    if p[i].Character:FindFirstChild("Playing") then
    count = count + 1
    end
    end
    end
    repeat DeathMatch() Wait(0.2) until count <= 1 -- Wait added here
Report Abuse
Voxhall is not online. Voxhall
Joined: 22 Apr 2009
Total Posts: 21504
13 Dec 2012 03:55 PM
[ Content Deleted ]
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
13 Dec 2012 03:55 PM
This isn't meet and greet forum
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
13 Dec 2012 08:22 PM
Thanks crazy, I'll try that out and see if it work, but I think the main problem was that "count" was local to that function.

~SamuelKingx
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
14 Dec 2012 07:44 PM
Crazyman, it still didn't work.
If you get a chance/ever come back to this thread, please message me and I'll tell you what's going on.

~SamuelKingx
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
14 Dec 2012 08:39 PM
UMG STOLE MY SCRIPT D:<
:P

~LUV, LuaLearners Teacher(+2)~
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
14 Dec 2012 09:37 PM
Nut uhh, nub . :P

~SamuelKingx
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