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 » Scripters
Home Search
 

Re: Is this efficient

Previous Thread :: Next Thread 
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
23 May 2015 07:29 AM
they tell me inefficient but wont tell me WHY
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
23 May 2015 07:29 AM
this post is inefficient
Report Abuse
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
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
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
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
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
23 May 2015 07:40 AM
Still wrong.

http://wiki.roblox.com/index.php?title=Writing_Clean_Code
Report Abuse
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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 is not online. 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
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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
BumpMachine is not online. BumpMachine
Joined: 11 May 2015
Total Posts: 399
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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