DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 24 Jan 2014 11:31 PM |
Like i know i have to use
game.Players.PlayerAdded:connect(function(p) game.Players:GetChildren() end)
But like i don't know how to add it to a list |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2014 11:35 PM |
game.Players:GetPlayers()
This already gives you a table with all the players, no need to use the method above. UNLESS you want to save ALL the players that come in, even if they leave:
list = {}
game.Players.PlayerAdded:connect(function(p) list[p.Name] = true --in case they come back end)
for i in pairs(list) do print(i.." is the name of yet another person who visited..."); end |
|
|
| Report Abuse |
|
|
Thaeh
|
  |
| Joined: 05 Feb 2011 |
| Total Posts: 7685 |
|
|
| 24 Jan 2014 11:35 PM |
PlayerList = {}
for i, v in pairs(game.Players:GetChildren()) do PlayerList[i] = v end
print(PlayerList[1])
Untested |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 24 Jan 2014 11:36 PM |
for _,v in pairs(game.Players:getChildren()) do m = Instance.new("Message", game.Workspace) m.Text = v.Name .. " is a player" wait(1) m:Destroy() end
or if that's not what you mean here is making a table of the players.
list = game.Players:GetChildren()
while wait(1) do -- This is for an updating effect, whenever a player enters the server, they will add. --stuff calling the table
|
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 24 Jan 2014 11:42 PM |
Ok so if i were to make a GUI,
How can i check if like the TextLabel/TextButton has already a player in it go to check the next one?
Like instead of printing, something like this:
list = {}
game.Players.PlayerAdded:connect(function(p)
gui = p.PlayerGui.List
list[p.Name] = true --in case they come back end)
for i in pairs(list) do gui.Frame.TextButton.Text = i end
but instead like i said it checks if a player is already in that textbutton so it checks the next one and next one. |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
| |
|
|
| 24 Jan 2014 11:50 PM |
| So its like finding a player using a TextLabel or a TextButton? I didn't understand your explanation really well. |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 24 Jan 2014 11:57 PM |
Ok so the list of players.
There is 12 people MAX per server. On this GUI it will have 12 textbuttons that are empty.
This script will activate and it will get the list of players. Then when that player joined they got added on the GUI. So it will add it to the starterGUI and the playersGUI.
But if someone is already added to the first textbutton it will go to the next and add the player name to it.
EX: Player1 Joins the server and Player2 was already in it and Player2 already joined before him so in Player2's GUI it will add Player1 on the GUI but Player2 is already on the first TextButton so Player1 will go on the next TextButton. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 12:07 AM |
--Assuming the 12 buttons are called TextButton1, TextButton2, ..., TextButton12 --And assuming they are in StarterGui.ScreenGui.Frame and PlayerGui.ScreenGui.Frame
sg = "ScreenGui" --will need this, trust me root = "TextButton" --this means the part of the name all the buttons share, without the number
game.Players.PlayerAdded:connect(function(p) local f = game.StarterGui:findFirstChild(sg) and game.StarterGui[sg]:findFirstChild("Frame") --change if the Frame with the 12 buttons has another name if f then for i, v in pairs(f:children()) do if v.Name:sub(1, #root):lower() == root:lower() then if v.Text == "" then v.Text = p.Name for _, e in pairs(game.Players:GetPlayers()) do e.PlayerGui[sg][f.Name][v.Name].Text = p.Name end break end end end end end)
game.Players.PlayerRemoving:connect(function(p) local f = game.StarterGui:findFirstChild(sg) and game.StarterGui[sg]:findFirstChild("Frame") --change if the Frame with the 12 buttons has another name if f then for i, v in pairs(f:children()) do if v.Name:sub(1, #root):lower() == root:lower() then if v.Text == p.Name then v.Text = "" for _, e in pairs(game.Players:GetPlayers()) do e.PlayerGui[sg][f.Name][v.Name].Text = "" end break end end end end end) |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 25 Jan 2014 12:09 AM |
| ^Feeling generous today..? |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 12:11 AM |
| Nope, its a fun request, I tried doing that once and failed. T_T |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 12:30 AM |
| Thanks! Also do you know the respawn function? I keep on forgetting. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 05:07 PM |
Uhm what do you mean respawn function? Like making all players respawn?
for i, v in pairs(game.Players:GetPlayers()) do v:LoadCharacter() end
Or like doing something when they respawn?
game.Players.PlayerAdded:connect(function(p) p.CharacterAdded:connect(function(c) print(p.Name, "Has just respawned!") end) end) |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 08:03 PM |
NVM.
Anyways about your thing, It works but only on the first TextButton Like it shows my friends name but not mine on the list. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 08:23 PM |
Ehhh a simpler version, put this inside the Frame that has the 12 buttons on it:
(It will make the list when you spawn, if someone leaves it should remove them from the list)
local n = 1 local p = game.Players:GetPlayers() local c = script.Parent:children() local f = false for n = n, 12 do if p[n] then if c[n]== script then f = true else c[f and n+1 or n].Text = p[n].Name end end end
game.Players.PlayerRemoving:connect(function(p) for i, v in pairs(c) do if v ~= script then if v.Text == p.Name then v.Text = "" end end end end) |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 08:38 PM |
Is there a way to make it where it changes auto when someone joins without having to respawn/reset?
it does work though |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 08:51 PM |
Ah, forgot to add that...
local n = 1 local p = game.Players:GetPlayers() local c = script.Parent:children() local f = false for n = n, 12 do if p[n] then if c[n]== script then f = true else c[f and n+1 or n].Text = p[n].Name end end end
game.Players.PlayerRemoving:connect(function(p) for i, v in pairs(c) do if v ~= script then if v.Text == p.Name then v.Text = "" return end end end end)
game.Players.PlayerAdded:connect(function(p) for i, v in pairs(c) do if v ~= script then if v.Text == "" then v.Text = p.Name return end end end end) |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 09:50 PM |
Also if you can help me on this script since you were a great helper on this one. It seems that when you click one of the button it does not add the value. Here is what i have:
p = script.Parent.Text f = script.Parent.Parent
script.Parent.MouseButton1Down:connect(function(c) f.Visible = false f.Parent.Frame1.Visible = true f.Parent.Frame1.Player.Value = p end)
So if it isn't that then it is this because it does not clone the class Tool to that person has in their Character not backpack. (basicly meaning it gives that person the tool that the person is holding and removes it from their tools/workspace tools.) Here is what i have:
p = script.Parent.Parent.Player.Value
for _, Object in pairs (Game.Players.LocalPlayer.Character:GetChildren()) do if Object:IsA("Tool") then q:Clone().Parent = game.Workspace[p] q:Destroy() script.Paent.Parent.Visible = false script.Parent.Parent.Parent.Frame.Visible = true else script.Parent.Parent.Error.Text = "ERROR: No Tool" wait(1) script.Parent.Parent.Error.Text = "" script.Parent.Parent.Visible = false script.Parent.Parent.Parent.Frame.Visible = true end end |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2014 10:03 PM |
Your variable p is 'outdated', because when the text changes, the variable p doesn't:
f = script.Parent.Parent
script.Parent.MouseButton1Down:connect(function(c) p = script.Parent.Text f.Visible = false f.Parent.Frame1.Visible = true f.Parent.Frame1.Player.Value = p end) |
|
|
| Report Abuse |
|
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 10:20 PM |
It still won't work though.
Like i have a text that displays the players name but doesn't display it:
while true do script.Parent.Text = script.Parent.Parent.Player.Value end
and this still won't work:
p = script.Parent.Parent.Player.Value
for _, Object in pairs (Game.Players.LocalPlayer.Character:GetChildren()) do if Object:IsA("Tool") then q:Clone().Parent = game.Workspace[p] q:Destroy() script.Paent.Parent.Visible = false script.Parent.Parent.Parent.Frame.Visible = true else script.Parent.Parent.Error.Text = "ERROR: No Tool" wait(1) script.Parent.Parent.Error.Text = "" script.Parent.Parent.Visible = false script.Parent.Parent.Parent.Frame.Visible = true end end |
|
|
| Report Abuse |
|
|
| |
|
DailyTime
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 285 |
|
|
| 25 Jan 2014 10:41 PM |
Now that i fixed that now my whole game just broke.
Kohl's 'Your Admin' thing won't disappear and the GUI won't load and my FF won't go away. |
|
|
| Report Abuse |
|
|