Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:25 AM |
Trying to section out people in teams with a gui leaderboard, would this work?
for i = 1,#plr do item = script.Parent:findFirstChild("PlayerLabel" .. tostring(i)) if (item~=nil) then item.Visible = true item.Text = plr[i].Name -- this is the part where it's gonna section people if player.TeamColor == "Sand red" then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1)) end |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:27 AM |
why not
for i, v in pairs(game.Players:GetPlayers()) do if v.TeamColor == "color1" then -- label1 elseif v.TeamColor == "color2" then -- label2 end end |
|
|
| Report Abuse |
|
|
WishNite
|
  |
| Joined: 11 Feb 2009 |
| Total Posts: 15828 |
|
|
| 11 Jul 2014 10:28 AM |
| You should test it out and then post the output error if it has one :P |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
| |
|
| |
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:41 AM |
dispassion, i'm a little lost with what you posted, would i just put the label through script.Parent up there?
(sorry i'm just learning scripting lol) |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:41 AM |
ooops didnt even read the second part
if plr.TeamColor == BrickColor.new("Sand red") then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1)) end
try that
|
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:42 AM |
plr[i]
oh my I'm bad today, I listened to five hours of kokorokokorokokorokokorokokorokokorokokorokokorokokorokokorokokoro last night
if plr[i].TeamColor == BrickColor.new("Sand red") then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1)) end |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:42 AM |
nothing happens, just turns the labels blank
-- full script
print("Leaderboard loaded")
function update() wait() a = script.Parent:GetChildren() for i = 1,#a do if a[i].ClassName == "TextLabel" then a[i].Visible = false end end for i, v in pairs(game.Players:GetPlayers()) do if plr.TeamColor == BrickColor.new("Sand red") then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1)) elseif v.TeamColor == "Sand blue" then item = script.Parent:findFirstChild("DefenderPlayer" .. tostring(i))
end end end
function getNumber(obj) for i = 1,#plr do if plr[i]==obj then return i end end end
plr = {} p = game.Players:GetChildren()
for i = 1,#p do table.insert(plr, p[i]) end
update() game.Players.ChildAdded:connect(function (Playr) table.insert(plr, Playr) update() end) game.Players.ChildRemoved:connect(function (Playr) table.remove(plr, getNumber(Playr)) update() end) |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:44 AM |
updated
print("Leaderboard loaded")
function update() wait() a = script.Parent:GetChildren() for i = 1,#a do if a[i].ClassName == "TextLabel" then a[i].Visible = false end end for i, v in pairs(game.Players:GetPlayers()) do if plr[i].TeamColor == BrickColor.new("Sand red") then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1)) elseif plr[i].TeamColor == BrickColor.new("Sand red") then script.Parent:findFirstChild("DefenderPlayer" .. tostring(1))
end end end
function getNumber(obj) for i = 1,#plr do if plr[i]==obj then return i end end end
plr = {} p = game.Players:GetChildren()
for i = 1,#p do table.insert(plr, p[i]) end
update() game.Players.ChildAdded:connect(function (Playr) table.insert(plr, Playr) update() end) game.Players.ChildRemoved:connect(function (Playr) table.remove(plr, getNumber(Playr)) update() end) |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:45 AM |
for i, v in pairs(game.Players:GetPlayers()) do
if plr.TeamColor == BrickColor.new("Sand red") then script.Parent:FindFirstChild("RaiderLabel" .. tostring(1))
elseif v.TeamColor == "Sand blue" then item = script.Parent:findFirstChild("DefenderPlayer" .. tostring(i))
end
for i, v in pairs(game.Players:GetPlayers()) do if v.TeamColor == BrickColor.new("Sand red") then -- your labeling stuff elseif v.TeamColor == BrickColor.new("Sand blue") then -- your labeling stuff end |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:48 AM |
@dispassion
i take it i use the bottom part |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
| |
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:52 AM |
-- my entire thing right now
print("Leaderboard loaded")
function update() wait() a = script.Parent:GetChildren() for i = 1,#a do if a[i].ClassName == "TextLabel" then a[i].Visible = false end end for i, v in pairs(game.Players:GetPlayers()) do if v.TeamColor == BrickColor.new("Sand red") then item = script.Parent:FindFirstChild("DefenderPlayer" .. tostring(1)) if (item~=nil) then item.Visible = true item.Text = plr[i].Name
elseif v.TeamColor == BrickColor.new("Sand blue") then item = script.Parent:FindFirstChild("DefenderPlayer" .. tostring(1)) if (item~=nil) then item.Visible = true item.Text = plr[i].Name
end end end
function getNumber(obj) for i = 1,#plr do if plr[i]==obj then return i end end end
plr = {} p = game.Players:GetChildren()
for i = 1,#p do table.insert(plr, p[i]) end
update() game.Players.ChildAdded:connect(function (Playr) table.insert(plr, Playr) update() end) game.Players.ChildRemoved:connect(function (Playr) table.remove(plr, getNumber(Playr)) update() end) |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:52 AM |
script.Parent:findFirstChild("DefenderPlayer" .. tostring(1))
what are you using these lines for
they'll just return what they find or nil you're not actually doing anything with them |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:54 AM |
those are place holders for player names
i would add a variable such as item =
then
if (item~=nil) then item.Visible = true item.Text = plr[i].Name
i put this under it
but all it does it breaks the whole thing, before i add it it works and makes everything not visible but no names
but with it
it doesnt do anythinng |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2014 10:56 AM |
print("Leaderboard loaded")
function update() wait() a = script.Parent:GetChildren() for i = 1,#a do if a[i].ClassName == "TextLabel" then a[i].Visible = false end end
for i, v in pairs(game.Players:GetPlayers()) do if v.TeamColor == BrickColor.new("Sand red") then item = script.Parent:FindFirstChild("DefenderPlayer" .. tostring(1)) if (item~=nil) then item.Visible = true item.Text = plr[i].Name
elseif v.TeamColor == BrickColor.new("Sand blue") then item = script.Parent:FindFirstChild("DefenderPlayer" .. tostring(1)) if (item~=nil) then item.Visible = true item.Text = plr[i].Name
end end end end end
function getNumber(obj) for i = 1,#plr do if plr[i]==obj then return i end end end
plr = {} p = game.Players:GetChildren()
for i = 1,#p do table.insert(plr, p[i]) end
update() game.Players.ChildAdded:connect(function (Playr) table.insert(plr, Playr) update() end) game.Players.ChildRemoved:connect(function (Playr) table.remove(plr, getNumber(Playr)) update() end)
you were missing a few ends |
|
|
| Report Abuse |
|
|
Bleerp
|
  |
| Joined: 05 Nov 2012 |
| Total Posts: 3467 |
|
|
| 11 Jul 2014 10:57 AM |
| You're a life saver! thank you so much dispassion, I'll remember your gratitude friend :) |
|
|
| Report Abuse |
|
|
Azureous
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25287 |
|
|
| 11 Jul 2014 10:59 AM |
| I have a script for this, but I just now saw this so srry |
|
|
| Report Abuse |
|
|