How do I make a GUI appear when a player joins? This is stupid complicated for me sadly.
Remote event that fires when a player joins (script)
local event = game.ReplicatedStorage local Players = game:GetService("Players") game.Players.PlayerAdded:Connect(function(player) event.qeqeqeq:FireClient(player) end)
This is the gui that got fired (local script)
event.qeqeqeq.OnClientEvent:connect(function(plr) game.Players.CharacterAutoLoads = false Player.Humanoid.Health = 0 script.Parent.Parent.Parent.MenuButton.Visible = false script.Parent.Parent.Parent.Menu.Visible = true PlayerGUI.HealthGui.Enabled = false PlayerGUI.StatusUI.Enabled = false PlayerGUI.CurrentVersion.Enabled = false game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic SG:SetCoreGuiEnabled("Backpack", false) workspace.CurrentCamera.FieldOfView = 110 Player.Humanoid.Died:Connect(function() Player:Remove() end) end)
THIS script works in studio but when I join a game it doesn't work for some reason.
There most likely explanation is that when you play the game outside of studio, PlayerGui (and all its local scripts) load much slower. So when server fires and event to the client, this your LocalScript
have not loaded yet.
Elegant solution would be for a client to fire a special "Ready" event, so that server could fire its own event. Most people however are happy with adding wait(10)
(10 seconds is a pure guess here), before firing any Remotes
to clients.
However. Since you want all of this to happen on player join, why use event at all? you can simply get rid of the function and just put this code directly in any local script.
EDIT: If do not want it to run or reset, place it in StarterPlayerScripts
or in ScreenGui
with ResetOnSpawn
property set to false
--proper way to get player in LocalScripts: local Player = game.Players.LocalPlayer game.Players.CharacterAutoLoads = false -- this should be done on server, has no effect here. Player.Humanoid.Health = 0 script.Parent.Parent.Parent.MenuButton.Visible = false script.Parent.Parent.Parent.Menu.Visible = true PlayerGUI.HealthGui.Enabled = false PlayerGUI.StatusUI.Enabled = false PlayerGUI.CurrentVersion.Enabled = false Player.CameraMode = Enum.CameraMode.Classic SG:SetCoreGuiEnabled("Backpack", false) workspace.CurrentCamera.FieldOfView = 110 Player.Humanoid.Died:Connect(function() Player:Remove() end)
And finally, most of this stuff can be set in studio settings. Click on Players
in studio to switch off CharacterAutoLoads
in properties window for example. You can also set Gui Elements to Visible, and hide them by clicking on the "Eye" icon in the top right corner, when you are not editing GUI.
Yo, TheBuilderMc. How about making the gui visible when the person joins the game LOL