|
| 23 May 2015 07:29 AM |
| they tell me inefficient but wont tell me WHY |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
|
| 23 May 2015 07:29 AM |
Opps i forgot the code: local function FindPlayer(Speaker,Var)
local ReturnedPlayers = {}
for _,v in ipairs(game.Players:GetPlayers()) do if v.Name:lower():sub(1,#Var) == Var:lower() then return{v} end end if Var:lower() == "me" then return{Speaker} end if Var:lower() == "all" then for _,v in pairs(game.Players:GetChildren()) do table.insert(ReturnedPlayers,v) end end if Var:lower() == "elders" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge >= 80 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "noobs" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge < 25 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "others" then for _,v in pairs(game.Players:GetChildren()) do if v.Name ~= Speaker.Name then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "guests" then for _,v in pairs(game.Players:GetChildren()) do if v.Name:match("Guest ") then table.insert(ReturnedPlayers,v) end end end return ReturnedPlayers end |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:34 AM |
Can you fix your tabbing.
First obvious problem I see:
Var = Var:lower() -- Instead of that x 20 |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:35 AM |
i didnt tab it. Roblox did. XD
Also thats not the issue as it says name:lower() == var:lower()
Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143 |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:38 AM |
| I'm not going to help if you can't make readable code (Aka I have to do more work). |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:39 AM |
here
local function FindPlayer(Speaker,Var) local ReturnedPlayers = {} for _,v in ipairs(game.Players:GetPlayers()) do if v.Name:lower():sub(1,#Var) == Var:lower() then return{v} end end if Var:lower() == "me" then return{Speaker} end if Var:lower() == "all" then for _,v in pairs(game.Players:GetChildren()) do table.insert(ReturnedPlayers,v) end end if Var:lower() == "elders" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge >= 80 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "noobs" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge < 25 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "others" then for _,v in pairs(game.Players:GetChildren()) do if v.Name ~= Speaker.Name then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "guests" then for _,v in pairs(game.Players:GetChildren()) do if v.Name:match("Guest ") then table.insert(ReturnedPlayers,v) end end end return ReturnedPlayers end
Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143 |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:40 AM |
Still wrong.
http://wiki.roblox.com/index.php?title=Writing_Clean_Code |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:42 AM |
local function FindPlayer(Speaker,Var) local ReturnedPlayers = {} for _,v in ipairs(game.Players:GetPlayers()) do if v.Name:lower():sub(1,#Var) == Var:lower() then return{v} end end if Var:lower() == "me" then return{Speaker} end if Var:lower() == "all" then for _,v in pairs(game.Players:GetChildren()) do table.insert(ReturnedPlayers,v) end end if Var:lower() == "elders" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge >= 80 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "noobs" then for _,v in pairs(game.Players:GetChildren()) do if v.AccountAge < 25 then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "others" then for _,v in pairs(game.Players:GetChildren()) do if v.Name ~= Speaker.Name then table.insert(ReturnedPlayers,v) end end end if Var:lower() == "guests" then for _,v in pairs(game.Players:GetChildren()) do if v.Name:match("Guest ") then table.insert(ReturnedPlayers,v) end end end return ReturnedPlayers end
Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143 |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 23 May 2015 07:43 AM |
| You know, I'd actually make your functions return an iteration ready function instead because it looks nicer. |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:43 AM |
@e
you sound so smart lol
i think you mean return but that causes issues with multi-players:
it stops at the first player. Thats why i switched.
Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143 |
|
|
| Report Abuse |
|
|
|
| 23 May 2015 07:47 AM |
this is what happens.
they say do something i do it and..
then they dont help...
Admin? http://www.roblox.com/Bumps-Admin-Commands-item?id=250209143 |
|
|
| Report Abuse |
|
|