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: Help

Previous Thread :: Next Thread 
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 03:43 PM
This script is giving me a problem. It's supposed to find who has the most Points
local player, score = 0;

for _, v in pairs(game:GetService('Players'):GetPlayers())
if (v.leaderstats.Points > score) then --line with problem
score = v.leaderstats.Points;
player = v.Name;
end;
end;
Report Abuse
manofthebase44 is not online. manofthebase44
Joined: 14 Feb 2012
Total Posts: 2221
13 Aug 2013 03:45 PM
Just add a do to line 2
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 03:46 PM
Oh, my bad, I forgot to add that here, I did it in studio. Here's script again:

for _, v in pairs(game:GetService('Players'):GetPlayers()) do
if (v.leaderstats.Points > score) then --line with problem
score = v.leaderstats.Points;
player = v.Name;
end;
end;
Report Abuse
manofthebase44 is not online. manofthebase44
Joined: 14 Feb 2012
Total Posts: 2221
13 Aug 2013 03:46 PM
And then is the leaderstats, another part to the script? or is their a parent to it?
Report Abuse
As8D is online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
13 Aug 2013 03:46 PM
I don't think there's a property named 'Points'... well, there's 'Score' for the object Team.

I assume Points is an IntValue/NumberValue, so you want to access the Value property.

local player, score = "", 0; -- Otherwise, player would be 0 and score would be nil.

for _, v in pairs(game:GetService('Players'):GetPlayers())
if (v.leaderstats.Points.Value > score) then
score = v.leaderstats.Points.Value;
player = v.Name;
end;
end;


- As, you can use table.sort to do magical stuff... woah, flying cows!
Report Abuse
manofthebase44 is not online. manofthebase44
Joined: 14 Feb 2012
Total Posts: 2221
13 Aug 2013 03:47 PM
/\
xD just like the question I said but more advanced. Again you missed "do" :D
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 03:47 PM
leaderstats is from players..
Report Abuse
manofthebase44 is not online. manofthebase44
Joined: 14 Feb 2012
Total Posts: 2221
13 Aug 2013 03:49 PM
No is there another part to the script, cause Leadestats, isn't a member of game.Players ;\
Report Abuse
manofthebase44 is not online. manofthebase44
Joined: 14 Feb 2012
Total Posts: 2221
13 Aug 2013 03:50 PM
#Players :D
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 03:57 PM
@As, when I did that, all of my scripts stopped working? @PersonWho'sAskingAboutLeaderstats It's a pair function
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 04:01 PM
script now(It stopped all my scripts from working) while true do
for i,v in pairs(game.Players:GetChildren()) do
v.TeamColor = BrickColor.new("Bright yellow")
v.leaderstats.Votes.Value = 0
plist = game.StarterGui.Voting.plist

wait(5) -- time until next election
plist.Visible = true
wait(5) --time for them to vote
plist.Visible = false


local player, score = "", 0; -- Otherwise, player would be 0 and score would be nil.

for _, v in pairs(game:GetService('Players'):GetPlayers())do
if (v.leaderstats.Votes.Value > score) then
score = v.leaderstats.Votes.Value;
player = v.Name;
end;
end;
m = Instance.new("Message", Workspace)
m.Text = player.. " has won the elections!"
wait(3) -- time until message gets destroyed
m:Destroy()
player.TeamColor = BrickColor.new("Bright blue") --Put President team Color here
--ab = game.StarterGui.plist

end
end
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 04:15 PM
Someone?
Report Abuse
As8D is online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
13 Aug 2013 04:20 PM
Any output?

If not, try add in prints... or find out where it stops. :/

- As, oh, my ziggy just dumped down here again.
Report Abuse
shawnyg is not online. shawnyg
Joined: 21 Apr 2011
Total Posts: 1428
13 Aug 2013 06:20 PM
Well, this script is stopping all my scripts from working.... when I try to see what output says by click play, crashes..
Report Abuse
As8D is online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
14 Aug 2013 02:57 AM
Hm.


I don't see anywhere where it could possibly run through the election in no time, thus ending in a while true do loop.

You can add in prints followed by.. if true then return end? Then we'll know if it's the script that's acting weird. Or it could be another script that's reacting on changes made from this script?

- As, obsculencus.
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