Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 01:29 PM |
My code needs to run when there is two players, and I refer to player a lot, but how do I get a player from a S3#v############it's not triggered by a hit function on PlayerAdded function.
Code:
local RE = game.ReplicatedStorage:WaitForChild("GameEvent") local round = false local choose = false local afk = false local playing = false local player = ----- ??????? HELP local label = player.PlayerGui.Main.Frame.Label local time = player.PlayerGui.Main.Frame.Time repeat wait() until player.Character local char = player.Character
if game.Players.NumPlayers >= 2 then print('Connected!') ---- Intermission ---- if not round then print('Intermission') label.Text = "Intermission" for i = 15, 0, -1 do time.Text = i wait(1) choose = true end end ---- Choose Element ---- if choose then print('Choosing!') label.Text = "Choose your Element!" for i = 10, 0, -1 do time.Text = i wait(1) round = true end end ---- Round ---- if round then print('Round!') label.Text = "Round in Progress" for i = 120, 0, -1 do time.Text = i wait(1) round = false end end end
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:00 PM |
FE is on btw
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:09 PM |
| game.Players:GetChildren() makes a table of all players, then you can use a loop to iterate over each player |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:14 PM |
Can you give me an example pls
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 27 Feb 2017 02:17 PM |
for i,v in next, game.Payers:GetPlayers() do
end
|
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:22 PM |
"ServerScriptService.Scripts.GameScripts.Main:7: attempt to index field 'PlayerGui' (a nil value)
New Code: local RE = game.ReplicatedStorage:WaitForChild("GameEvent") local round = false local choose = false local afk = false local playing = false local player = game.Players:GetChildren() local label = player.PlayerGui.Main.Frame.Label local time = player.PlayerGui.Main.Frame.Time repeat wait() until player.Character local char = player.Character
for i,v in next, game.Playerss:GetPlayers() do if game.Players.NumPlayers >= 2 then print('Connected!') ---- Intermission ---- if not round then print('Intermission') label.Text = "Intermission" for i = 15, 0, -1 do time.Text = i wait(1) choose = true end end ---- Choose Element ---- if choose then print('Choosing!') label.Text = "Choose your Element!" for i = 10, 0, -1 do time.Text = i wait(1) round = true end end ---- Round ---- if round then print('Round!') label.Text = "Round in Progress" for i = 120, 0, -1 do time.Text = i wait(1) round = false end end end end
Line: local label = player.PlayerGui.Main.Frame.Label
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:28 PM |
fixed that not working
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:30 PM |
my whole script isn't working
same error
how2fix?
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:31 PM |
should I define the player after the for i,v in next?
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:39 PM |
| Guessing you are using FE. You cannot access PlayerGui with # ############ with FE enabled |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 02:46 PM |
you can access playergui with FE.
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:48 PM |
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=188224284
"but with FE it cannot access PlayerGui" |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:50 PM |
:GetChildren() returns a table you need to iterate through it to get individual players
|
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:53 PM |
local players = game.Players:GetChildren() for _,v in pairs(players) do v.PlayerGui.--add stuff here end
|
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 02:54 PM |
@Mister
"v.PlayerGui"
again you cannot access playergui from server scripts |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 03:00 PM |
| http://wiki.roblox.com/index.php?title=API:Class/PlayerGui |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 03:01 PM |
@Mister
He is using FE ffs read the above posts |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 03:05 PM |
| It's not working, but I might be doing something wrong, here is my code: (All in # ############ btw) for _,v in pairs(players) do if game.Players.NumPlayers >= 2 then print('Connected!') ---- Intermission ---- if not round then print('Intermission') v.PlayerGui.Main.Frame.Text = "Intermission" for i = 15, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) choose = true end end ---- Choose Element ---- if choose then print('Choosing!') v.PlayerGui.Main.Frame.label.Text = "Choose your Element!" for i = 10, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) round = true end end ---- Round ---- if round then print('Round!') v.PlayerGui.Main.Frame.label.Text = "Round in Progress" for i = 120, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) round = false end end end end ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 03:06 PM |
for _,v in pairs(players) do if game.Players.NumPlayers >= 2 then print('Connected!') ---- Intermission ---- if not round then print('Intermission') v.PlayerGui.Main.Frame.Text = "Intermission" for i = 15, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) choose = true end end ---- Choose Element ---- if choose then print('Choosing!') v.PlayerGui.Main.Frame.label.Text = "Choose your Element!" for i = 10, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) round = true end end ---- Round ---- if round then print('Round!') v.PlayerGui.Main.Frame.label.Text = "Round in Progress" for i = 120, 0, -1 do v.PlayerGui.Main.Frame.time.Text = i wait(1) round = false end end end end
in a S3RV3R SCR1PT
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
Eventive
|
  |
| Joined: 28 Jul 2011 |
| Total Posts: 9827 |
|
|
| 27 Feb 2017 03:07 PM |
How do I do this then?!?! Can you guys just give the code to me, fixed and everything? I learn better that way, I always say that.
ATR'er since 2013. |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2017 04:59 PM |
| http://wiki.roblox.com/index.php?title=API:Class/PlayerGui |
|
|
| Report Abuse |
|
|