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: Would this work?

Previous Thread :: Next Thread 
Bleerp is not online. 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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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 is not online. 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 is not online. Bleerp
Joined: 05 Nov 2012
Total Posts: 3467
11 Jul 2014 10:35 AM
No, it doesn't :(
Report Abuse
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
11 Jul 2014 10:37 AM
object hierarchy pls
Report Abuse
Bleerp is not online. 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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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 is not online. 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 is not online. 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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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 is not online. 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 is not online. Bleerp
Joined: 05 Nov 2012
Total Posts: 3467
11 Jul 2014 10:49 AM
nothings working lol :///
Report Abuse
Bleerp is not online. 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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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 is not online. 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
Dispassion is not online. Dispassion
Joined: 13 Sep 2013
Total Posts: 180
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 is not online. 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 is not online. 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
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