Hey developers, Is it possible to change all the players GUI in a server script without using the remote event feature?
I don't like to use remote events because the scripts get very messy and I will like everything to run in one script...
This what I got at the moment, any help?
wait(1) game:WaitForChild("Players") for _, players in pairs(game.Players:GetPlayers()) do if players:FindFirstChild("PlayerGui") then players.PlayerGui.ChooseName.Enabled = true end end
Error: ChooseName is not a valid member of PlayerGui
EDIT: I HATE ADS!!!!!!!!
You might have to put everything into two or more scripts, because it just won't work in one (well, it might). It is a little messy. I say instead of using Events
or RemoteEvents
, use Values
and the .changed
function trigger. Like so:
This is for something like a rounds game with two teams:
Import these lines of code in the Command Prompt (Note that you can do any value type or name you want):
local sValue = Instance.new("BoolValue", game.ServerStorage) -- This is the Value for Server-Side scripts to access.
sValue.Name = "Team1Won"
local lValue = Instance.new("BoolValue", game.ReplicatedStorage) -- This is the value for Client-Side Scripts to access.
lValue.Name = "Team1Won"
local sValue2 = Instance.new("BoolValue", game.ServerStorage) -- This is the Value for Server-Side scripts to access.
sValue.Name = "GameInProgress"
local lValue2 = Instance.new("BoolValue", game.ReplicatedStorage) -- This is the value for Client-Side Scripts to access.
lValue.Name = "GameInProgress"
Whenever you want to say that "Team 1 won the game!", you can just set this value to true.
However, we need to do something about the fact that team 1 won/lost.
Inside the player's GUI, (via StarterGUI
) we need to make changes. You can add whatever suits you from here, or change the scripts to your needs.
For Client-Side Scripts
:
local lv1 = game.ReplicatedStorage:FindFirstChild(" "--[[Whatever your name was]]) local lv2 = game.ReplicatedStorage:FindFirstChild(" "--[[Whatever your name was]]) lv2.Changed:Connect(function(property) if lv2.Value = false then --Whatever value you want, really if lv1 = true then -- Add your own code for Team One's loss end if lv2 = true then --Add your own code for Team One's viscory end end end)
For Server-Side Scripts
:
local sv1 = game.ServerStorage:FindFirstChild(" "--[[Whatever your name was]]) local sv2 = game.ServerStorage:FindFirstChild(" "--[[Whatever your name was]]) sv2.Changed:Connect(function(property) if sv2.Value = false then --Whatever value you want, really if sv1 = true then -- Add your own code for Team One's loss end if sv2 = true then --Add your own code for Team One's viscory end end end)