game.Players.PlayerAdded:Connect(function() local plr = script.Parent plr.Enabled = true end)
This is a shorten version of the full script. This local script is inside a screengui. I want the screengui to be enabled but it doesnt work. Please help!
Hey, RebornedSnoop
The reason that your PlayerAdded
event is not firing is that when on the client-side, the code will not fire when the client joins. The event actually fires when a new player joins. So plr.Enabled
would not actually become true until a new player joins. To prevent this, I suggest using the PlayerAdded
event on the server when you can. You can then proceed to connect the event to the client through a RemoteEvent
. If you MUST use the client, then instead of wrapping it in a function, just get rid of the function and the script will play as soon as the code loads.
Another way you could do this is putting the ui in replicated and cloning it:
game.Players.PlayerAdded:Connect(function(Player) local UI = game.ReplicatedStorage.UI:Clone() UI.Parent = Player.PlayerGui end)
The game.Players.PlayerAdded
event does not work on the server. I would recommend to use that event on the server and then fire to the client using a remote event. Then, on the client enable the gui when the remote event is fired.