Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I change a players gui with FE?

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!"

2 comments

0

this is for a minigame place, so I want it to be everyone - not just a local script

1

GetPlayers creates a table with the players, so you got to use a for loop. :P

2 answers

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.

1 comment

0

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.