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
 

KOs and Tables

Previous Thread :: Next Thread 
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:05 PM
the part that I know for a fact isn't working is the last part of the 6th line.

"with "..players[1].KOs.Value.."[s]!")

for some reason the path to KOs isn't there, even if I put leaderstats between "players[1]" and "KOs"


game.Players.PlayerAdded:wait()
local players = game.Players:GetPlayers()
table.sort(players, function(val1, val2)
return val1.KOs.Value > val2.KOs.Value
end)
print("The person with the most KOs is: " .. players[1].Name.."with "..players[1].KOs.Value.."[s]!")

output says:
21:04:13.883 - KOs is not a valid member of Player
21:04:13.886 - Script 'ServerScriptService.Most KOs/WOs/Points Script', Line 6
21:04:13.887 - Stack End
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:09 PM
"KOs is not a valid member of Player"
pretty self-explanatory
you sure you don't mean player.leaderstats.KOs?
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:12 PM
I put that there too... it still went into error

21:11:55.925 - leaderstats is not a valid member of Player
21:11:55.926 - Script 'ServerScriptService.Most KOs/WOs/Points Script', Line 6
21:11:55.927 - Stack End
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Aug 2015 08:13 PM
local players = game.Players:GetPlayers()

table.sort(players,function(a,b)
return a.Kills.Value > b.Kills.Value
end)

for i,v in next, players do
print(v[1].Name.." has the most kills!"
print(v[2].Name.." has the second most kills!"
end
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 08:14 PM
@time
your script is exactly the same as OP's

make sure that your KOs value is actually in leaderstats

and use WaitForChild() if you think it is necessary
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:19 PM
^actually his would error

OP, show us your hierarchy structure
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:20 PM
where should I put the waitforchild so its most efficient?

Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
19 Aug 2015 08:22 PM
You put it where your script can't move any further without the item///

while true do the do
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:22 PM
OP, show us your hierarchy structure [2]

and yes I enumerate my own statements
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:24 PM
Players -> Player -> leaderstats -> KOs
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 08:26 PM
local players = game.Players:GetPlayers()

table.sort(players, function(plr1, plr2)
plr1:WaitForChild("leaderstats"):WaitForChild("KOs").Value > plr2:WaitForChild("leaderstats"):WaitForChild("KOs").Value
end)

for i, v in ipairs(players) do
print(v.leaderstats.KOs.Value)
end
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Aug 2015 08:27 PM
local players = game.Players:GetPlayers()

table.sort(players, function(a, b)
return a.KOs.Value > b.KOs.Value
end)

for i = 1, #players do
print(players[1].Name.." has the most kills!"
print(players[2].Name.." has the second most kills!"
end
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:31 PM
the greater than symbol goes into error because it was expecting an equal sign
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:31 PM
^I don't think that's meant to be in a for loop since it's pretty much hardcode.

Tell us if instawin's code works
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:33 PM
it won't accept the greater than symbol, for some reason it's waiting for an equal sign
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:40 PM
b1
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:41 PM
looks like he forgot a return in his sort

table.sort(players, function(plr1, plr2)
return plr1:WaitForChild("leaderstats"):WaitForChild("KOs").Value > plr2:WaitForChild("leaderstats"):WaitForChild("KOs").Value
end)
Report Abuse
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
19 Aug 2015 08:42 PM
He forgot to add a return.

table.sort(players, function(plr1, plr2)
return plr1:WaitForChild("leaderstats"):WaitForChild("KOs").Value > plr2:WaitForChild("leaderstats"):WaitForChild("KOs").Value
end)
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:52 PM
oddly enough, nothing shows up in output

nothing at all
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:54 PM
because it's waiting forever and nothing with that name is ever popping up
waitforchild does not work if an instance is already in there but then gets renamed to whatever is being waited for (unless that's what this recent talk of waitforchild being updated is about).
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 08:55 PM
so

should I try to use repeat wait() until instead?
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
19 Aug 2015 08:57 PM
you could try it I suppose, though you might be running into the same problem I was experiencing earlier today: http://www.roblox.com/Forum/ShowPost.aspx?PostID=171774177

to which I have no explanation for, just that it never had happened before
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 08:58 PM
sorry that i'm a scrub l0l
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 09:00 PM
lol your good, we can figure it out
Report Abuse
PureVoid is not online. PureVoid
Joined: 25 Dec 2011
Total Posts: 2624
19 Aug 2015 09:02 PM
when I check the test server, everything is loaded... the player, the leaderstats and the KOs are all there, but idk why it isn't loading.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
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