TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 03:06 PM |
for i,v in pairs(game.Players:GetChildren()) do --stuff end
How would I use a remote function/event for this? |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 04:08 PM |
As far as I know, you can't loop through players in a local script due to security reasons.
To use a RemoteFunction/Event you would do this:
--Server Script local RF = Instance.new("RemoteFunction", game.ReplicatedStorage) RF.Name = "RF"
local PlayersTable = {}
for i, v in pairs(game.Players:GetPlayers()) do table.insert(PlayersTable, v) end
RF.OnServerInvoke:connect(function(player, argument) if argument == "ShowPlayers" then return PlayersTable end end)
--Local Script local RF = game.ReplicatedStorage:WaitForChild("RF")
local PlayersTable = RF:InvokeServer("ShowPlayers")
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 04:10 PM |
"As far as I know, you can't loop through players in a local script due to security reasons. "
lolwat
OP why do you need to use a re?
u should add filtering - devious |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
| |
|
|
| 03 Jun 2015 04:26 PM |
lolwat [why?]
Huh?
I tried and it didn't work...
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 04:38 PM |
| Because if I try to loop through the players via local script, it won't work because of filtering. It will igve me an error saying PlayerGui is not a valid member of Player, I have the correct waitforchilds etc. I have to use a remote function/event to loop through the players for this to work then. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 03 Jun 2015 04:46 PM |
| Editing the PlayerGui's with FE is your problem, not because you can't loop through the players (which u can) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 06:49 PM |
@power I got this error message
19:48:34.938 - OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 06:51 PM |
use the following events
Event:FireServer() Event:FireClient() Event:FireAllClients()
Event.OnServerEvent Event.OnClientEvent |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:01 PM |
| Idiot, a localscript runs on the player's computer. The player's computer can only access their own PlayerGui. Just have a localscript that sets the localplayer's gui only, or if you're too stupid, then don't use FE considering that the number of exploiters on Roblox has decreased significantly. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:04 PM |
I'm basically just trying to clone a gui to all the players..i dont know why this has to be so difficult for me. This isn't working...
--server script? local RF = Instance.new("RemoteFunction", game.ReplicatedStorage) RF.Name = "RF" guiClone = gui:Clone()
function RF.OnServerInvoke(player,argument) for i, v in pairs(game.Players:GetPlayers()) do guiClone.Parent = v.PlayerGui end end
--local script? local RF = game.ReplicatedStorage:WaitForChild("RF")
local clone = RF:InvokeServer("CloneGui") |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:05 PM |
@nQ
My chat system did it just time.
But im wrewriting it to use fireallclients.
Anyways, you just misinformed him; it works, but not advisable. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:05 PM |
| @nQ, why don't you just hop off for once. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:10 PM |
| I can't seem to figure out how to loop through the players in the server script, then pass the gui from the local script, to the server event. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:16 PM |
@iSpecializinq What the hell are you even talking about? |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:17 PM |
| I can already tell you it's a bad practice to create the RemoteEvent inside the script rather than creating it inside ReplicatedStorage, then storing it in a variable, but that is the most I can do to help you since I'm not sure what you're trying to do. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:22 PM |
I want to do this:
--server script 1. Iterate over all the players 2. Import a gui from a local script and clone into the players' PlayerGuis
--local script 1. Clone the gui, send that gui to the server script
I'm am trying to get a gui from my playergui, clone it into all the other player's guis. With filtering enable, I can't just use "for i,v in pairs(game.Players:GetChildren()) do" in a local script and clone it into the players. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:23 PM |
| Do you not already have the GUI on the server? |
|
|
| Report Abuse |
|
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 03 Jun 2015 07:23 PM |
| I use game.Players:GetChildren() all the time in my local scripts. It works fine, that's with FE turned on. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:25 PM |
| The GUI is located in my PlayerGui, but it will only change with my own specific player settings. I want all the players to see these settings too, thus wanting me clone the gui from my playergui to their player guis. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:29 PM |
Send the stats through a RemoteEvent to the server, then distribute them to the clients through ClientEvents.
( ͡ಠ ͜ʖಠ) |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:29 PM |
| Then just send to the remoteevent the settings you changed. |
|
|
| Report Abuse |
|
|
gergy008
|
  |
| Joined: 16 Mar 2008 |
| Total Posts: 7039 |
|
|
| 03 Jun 2015 07:30 PM |
Right, I understand now.
So you could have some kind of server event that will listen to requests to modify all players GUIs, then have a listener in the GUI that will be triggered by the server with the changes required.
Then you just need to fill in the middle. Work out what changes to do and where on the clients, and how to get the request from the client and verify it, and send the changes to clients.
I'm pretty sure you're using documentation already, but links help, so I'll give you one: http://wiki.roblox.com/index.php?title=RemoteFunction_and_RemoteEvent_Tutorial |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Jun 2015 07:30 PM |
Okay this is my error. I thought is was because of FE.
local cell = player.PlayerGui:WaitForChild("Cell"):Clone()
for i,v in pairs(game.Players:GetChildren()) do cell.Parent = v.PlayerGui.MainGui.Main.Frame.List.Cells end
--playergui is not a valid member of player |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2015 07:31 PM |
| You_can't_loop_through_the_player's_playerguis_from_a_script_with_FE_on |
|
|
| Report Abuse |
|
|