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)
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.
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)
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.
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.