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

Why would won't the script change all the players text?

Please help?

wait(2)
--Waiting for players to choose name--
for i,v in pairs(game.Players:GetPlayers()) do
	v.PlayerGui.GameGui.Timers.TimerBackround.TextLabel.Text = "test"
end

Error: GameGui is not a valid member of PlayerGui

2 comments

0

Where is this script located?

0

server script

2 answers

✓ Accepted answer

Now that FE is enforced ScreenGui must be handled Client-sided.

So operations made to ScreenGui need be executed by a LocalScript (LocalScripts only run in certain locations, read more here).

(Special circumstances if the ScreenGui is somewhere on the Server or somewhere where it exists for both Server and Client(s). This is not the case for the PlayerGui folder of a Player).

Given this information we must understand that a LocalScript exists on a singular client. It does not replicate information between Clients. So this means that if a ScreenGui is in StarterGui along with a LocalScript. Then an individual LocalScript and ScreenGui exists for every player (every Client) that joins the game.

use a LocalScript, but if the server determines when the text changes then using a RemoteEvent to call the clients... look at the example below

--- <<<<< IN A SERVER SCRIPT  THAT IS IN SERVER STORAGE >>>>>>>
'

local textChanger = game.ReplicatedStorage.TextChanger

--When a certain event then 

textChanger:FireAllClients() -- Takes any defined parameters


--- <<<<<< IN A LocalScript THAT IS IN StarterGui 

local textChanger = game.ReplicatedStorage.TextChanger

textChanger.OnClientEvent:connect(function()

local player = game.Players.LocaPlayer

player.PlayerGui[ScreenGui][TextLabel].Text = "WOOOO HOOO.......It works"

-- I HOPE IT WORKS FOR YOU :D

end)

1 comment

0

don't put server scripts in ServerStorage, nothing runs there

This discussion is preserved as it was. New answers, comments, and votes are closed.