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

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

Asked by 6 years ago

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

0
Where is this script located? MRbraveDragon 374 — 6y
0
server script retrobricks 162 — 6y

2 answers

Log in to vote
1
Answered by
Pejorem 164
6 years ago

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.

Ad
Log in to vote
0
Answered by 6 years ago

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)
0
don't put server scripts in ServerStorage, nothing runs there User#22604 1 — 6y

Answer this question