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 |
|
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 13 Aug 2013 03:47 PM |
/\ xD just like the question I said but more advanced. Again you missed "do" :D |
|
|
| Report Abuse |
|
|
shawnyg
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
|
| 13 Aug 2013 03:47 PM |
| leaderstats is from players.. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 21 Apr 2011 |
| Total Posts: 1428 |
|
| |
|
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
|
  |
| 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
|
  |
| 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 |
|
|