Get every player's PlayerGui from a localscript

So, i’m trying to create an “update flight info” system that does exactly what the name says.

But, when I click “set info”, it only updates the client’s gui and says “playergui is not a valid member of Player2”.

Script

local set = script.Parent.Parent.Bg.Settings.Admin.Set


set.MouseButton1Click:Connect(function()
	print("Clicked")
	for i, player in pairs(game.Players:GetPlayers()) do
		local ui = player:WaitForChild("PlayerGui"):WaitForChild("Bg")
		local adminFrame = ui.Settings.Admin

		-- Admin
		local arr = adminFrame.Arrival.TextBox
		local dep = adminFrame.Departure.TextBox
		local flightno = adminFrame.FlightNo.TextBox


		-- Player
		local flightInfo = ui.FlightInfo
		local pl_dep = flightInfo.DepAirport
		local pl_arr = flightInfo.ArrAirport
		local pl_flightNo = flightInfo.FlightNumber


		pl_dep.Text = dep.Text
		pl_arr.Text = arr.Text
		pl_flightNo.Text = flightno.Text
		print("Set")
	end
end)

How do I fix this? Please help!

ALSO DOES NOTHING WHEN I USE A SS

3 Likes

Hi.

Sorry but I did not quite understand what you try to achieve. Could you please explain it in another way and with more details. You might be approaching this the wrong way.

2 Likes

So

This is part of an IFE I am making.

When an admin opens up the “settings” frame, they are able to update the flight info, such as the departure airport, arrival airport and the flight number.

When they hit “Set”, I want it to update on every player’s “Flight Info” frame, but instead, it only updates on the admin’s frame. (aka the client)

1 Like

Hi again,

I would suggest that you put a StringValue in ReplicatedStorage, and update the value of that StringValue. Then make so every client is listening to that StringValue, like the sample below.

--localscript
local ValueObject = .. -- path to your StringValue
local TextLabel = .. -- path to your TextLabel
ValueObject:GetPropertyChangedSignal("Value"):Connect(function()
	TextLabel.Text = ValueObject.Value -- Sets the TextLabels text to be equal to ValueObjects Value when it updates
end)
TextLabel.Text = ValueObject.Value -- Sets the TextLabels text to be equal to ValueObjects Value in its current state.

You’ll have to fire a remote to the server and pass through the text and then run that code on the server

Ahem, #help-and-feedback:scripting-support ,

Change it please

Alright so

Localscript:

  • Updates on the client

Serverscript

  • Doesn’t update the values
  • Updates the text, but sets it to “”

Ah yes, sorry about that mate! :+1:t5:

1 Like

The client cannot access the ‘PlayerGui’ container of other clients. You’ll need to fire the server via a ‘RemoteEvent’ object and then fire each client excluding the client which fired it.