|
| 08 Feb 2012 06:28 PM |
This function loops for some reason and I don't know why?
function waitStart() players = game.Players:GetPlayers() curPly = {} for _,v in pairs (players) do if (v.AFK.Value == false) then table.insert(curPly,v) else for i = #players, 1, -1 do -- I think it's because of this line table.remove(players,i) end v.PlayerGui.Main.Extras.AFKText.Visible = true end pcall(function() v.PlayerGui.Main.Alert.AT.Text = "Starting new game" v.PlayerGui.Main.Alert.AT2.Text = "Starting new game" end) end wait(2) if #players >= 3 then chooseA() else script.Disabled = true end end |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:30 PM |
for _,v in pairs (players) do for i = #players, 1, -1 do -- I think it's because of this line
Are both loops.
† KMXD † |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 06:31 PM |
1. (v.AFK.Value == false) Take a look at ( http://wiki.roblox.com/index.php/Bool ) because that's poor coding practice.
2. Check for if `waitStart()` is called inside `chooseA()` |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:33 PM |
@SD
So just "if v.AFK.Value not false"
?
† KMXD † |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
| |
|
|
| 08 Feb 2012 06:37 PM |
| @SDuke - It doesn't really matter. They both work fine. I just need to know how to re-arrange this function so it works? I know what the problem is now... it's because I have a loop inside a loop, but I don't know how to fix that. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:37 PM |
Oh, I didn't know not applied to booleans too. :S
And is == true acceptable?
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:38 PM |
Erm,
function waitStart() players = game.Players:GetPlayers() curPly = {} for _,v in pairs (players) do if (not v.AFK.Value) then table.insert(curPly,v) end else for i = #players, 1, -1 do -- I think it's because of this line table.remove(players,i) end v.PlayerGui.Main.Extras.AFKText.Visible = true end pcall(function() v.PlayerGui.Main.Alert.AT.Text = "Starting new game" v.PlayerGui.Main.Alert.AT2.Text = "Starting new game" end) end wait(2) if #players >= 3 then chooseA() else script.Disabled = true end
???
† KMXD † |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 06:39 PM |
| Just get rid of the second one completely. You don't need it. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 06:41 PM |
@knight
booleans are all that `not` works for. Just like it says on the page,
> In Lua, when something is converted to a boolean, if the value is false or nil then it will be false, otherwise it is true.
When you say
not workspace.Part
That's turning it into a boolean. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:41 PM |
| @SDuke - Uhhh, yeah I do? You don't know that the player needs to be removed from the table if he/she is in AFK mode. If they're not removed from the table, the whole script doesn't work. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 06:42 PM |
@brick You're inserting them into the `curPly` so just use that table. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 06:42 PM |
@SD
I see. So again, is == true acceptable?
† KMXD † |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 06:44 PM |
local bool=true; if bool then print("No ==true isn't good practice either."); end
Output : > No ==true isn't good practice either. |
|
|
| Report Abuse |
|
|
|
| 08 Feb 2012 07:01 PM |
What if you already have a bool value that is true, outside the script, already defined?
Would you still do if stuff.Value then?
† KMXD † |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 08 Feb 2012 07:04 PM |
| of course, Value will be equivalent of true so it's the same exact thing. |
|
|
| Report Abuse |
|
|