DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 18 May 2013 02:02 PM |
So I need to be able to change the properties of a GUI that all players have to where the GUI effect takes place across everyone's screen.
However in the code I used, it only does the changes for ONE player. If I use game.Players:GetPlayers(), it does the first one Alphabetically listed. If I used game.Players:GetChildren() it does the first one to join the server. (found after testing)
Below is the function I used to getplayers, and tag their GUI so I could manipulate it later. Any help on what I did wrong would be awesome.
function getplayers() for _, plyrs in pairs(game.Players:GetPlayers()) do if plyrs.PlayerGui then checkforgui = plyrs.PlayerGui.Reactor:FindFirstChild("Text") end end end
|
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 18 May 2013 02:13 PM |
game.Players.PlayerAdded:connect(function(player) if player.PlayerGui then checkforgui = player.PlayerGui.Reactor:findFirstChild("Text") -- do stuff here end end) |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 18 May 2013 02:14 PM |
I'm not all too familiar with other styles of coding, but the way I'd do this, it seems like you're trying to change a textlabel in everyone's GUI at the same time. What you should do is rename it to Message so it's not confused with a property (also called Text) and try the following:
players = game:GetPlayers()
function globalMsg(text) for i, v in pairs(players) do if v.PlayerGui:findFirstChild("Reactor") then v.Message.Text = text wait() else print("Reactor Gui not found for: " ..v.Name) end end end
|
|
|
| Report Abuse |
|
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 18 May 2013 02:31 PM |
| @Geo, your method works as expected in Studio, but flops in the actual game. |
|
|
| Report Abuse |
|
|
|
| 18 May 2013 02:41 PM |
| players = game:GetService("Players") |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 18 May 2013 02:44 PM |
| ^ What he said, sorry about that mistag, should fix my thingy |
|
|
| Report Abuse |
|
|