Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change a players gui with FE?

Asked by
Nickelz 37
6 years ago

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!"
0
this is for a minigame place, so I want it to be everyone - not just a local script Nickelz 37 — 6y
1
`GetPlayers` creates a table with the players, so you got to use a for loop. :P TheeDeathCaster 2368 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago

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.

0
script* Pumpk1n52 22 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Answer this question