I am trying to access a players gui in a FE game, I've asked this question before but had no useful answers.
when actived:
getplayers = game.Players:GetPlayers()
maintext = getplayers.PlayerGui.example.exampletext
maintext.Text = "Hello World!"
I am trying to access a players gui in a FE game, I've asked this question before but had no useful answers.
when actived:
getplayers = game.Players:GetPlayers()
maintext = getplayers.PlayerGui.example.exampletext
maintext.Text = "Hello World!"
You need to use a for do loop.
Your scripts would be:
for _, players in pairs(game.Player:GetPlayers()) do
maintext = players.PlayerGui.example.exampletext
maintext.Text = "Hello World!"
end
This looks trough all players in the game and changes their Gui text.
script*
On a regular script:
local RemoteEvent = Instance.new("RemoteEvent", game.Workspace)
RemoteEvent.Name = "ExampleRemote"
local text = "Hello World!" -- Change to whatever you want
RemoteEvent:FireAllClients(text)
On a local script located in StarterGui:
local RemoteEvent = game.Workspace:WaitForChild("ExampleRemote")
local maintext = game.Players.LocalPlayer.PlayerGui:WaitForChild("example")
:WaitForChild("exampletext")
function ChangeText(text)
maintext.Text = text
end
RemoteEvent.OnClientEvent:Connect(ChangeText)
Brief explanation: We are using FireAllClients() to make all players change their exampletext.Text to our text variable defined in the regular script. You can place your RemoteEvent somewhere else than the Workspace, just make sure to adjust the path defined in the first line of both scripts.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
this is for a minigame place, so I want it to be everyone - not just a local script
GetPlayerscreates a table with the players, so you got to use a for loop. :P