What im wanting to do is, after a Event Fires When a Player Clicks a button, it loads the character then i want it to set all the guis from Enabled false to Enabled True. It Does Set the Gui Enabled to true but the guis dont appear until the character resets. Is there a way to refresh the Gui to check and see if the Gui is enabled or not?
Code for the Enabling all guis.
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Event = ReplicatedStorage:FindFirstChild('EnableGui')
local StarterGui = game:GetService('StarterGui')
Event.OnServerEvent:Connect(function(Player, _)
if Player then
for _, gui in pairs (StarterGui:GetChildren()) do
if gui:IsA('ScreenGui') then
gui.Enabled = true
end
end
end
end)
Play around with the ScreenGui Property ResetOnSpawn. When that is true, the gui will be deleted and added again when the player respawns. If you set that to false, it will be like the player never died and everything will remain the same. This will be good if you want to implement custom visibility to a gui without worrying about it being reset when the player dies.
Yea. The All Guis (Except One) are Disabled By Defualt and i have a Intro Gui Which is visible. What im wanting to do is when the intro gui is not visible, Enable All Other Guis and Be Able to See them without Reseting the Character
For an intro, you want ResetOnSpawn to be false. That way a character respawning wont get the intro again. You can also just tell the intro to cover up everything by setting the zindex of the frame to be like 100 or something. That way it will cover up anything with a lower zindex.
ah. Do a loop over your guis and just set them to Disabled and then run the intro. The client will be handling the camera so at the same time you can run a LocalScript to change the visibility until the intro is over.
The server can also force a character to respawn using player:LoadCharacter() if you need that.
The issue is you’re changing the GUIs in StarterGui when you should be changing them in PlayerGui. Contents of StarterGui are cloned into a player’s PlayerGui when they spawn.
Knowing that, setting the properties of the UI in their PlayerGui will work:
for _, gui in pairs (game.Players.LocalPlayer.PlayerGui:GetChildren()) do
if gui:IsA('ScreenGui') then
gui.Enabled = true
end
end
Also just an FYI. It looks like you’re changing the client’s UI from the server. This is bad practice. The server can’t even see the UI on the client. Make it so when the player clicks the button, you just set the UI to be enabled directly from that local script. The character loading should stay on the server.
Most of these answers are localized; ie local-script related. When a player joins, clone the intro from where-ever and place it into game.Players.LocalPlayer.PlayerGui . This way, it’ll only happen when the player first joins.
– Server-Script in where-ever
game:GetService("Players").PlayerAdded;connect(function(player)
local intro = -- place where your intro ScreenGui is stored
intro:Clone().Parent = player:WaitForChild("PlayerGui")
end)
If you manually load your character via Player:LoadCharacter or Player.CharacterAutoLoads == false then, you have to wait until the character loads. Other than that, this should work as intended.