1st Box: When I have this script run I get this message " ServerScriptService.Script:2: attempt to index field 'PlayerGui' (a nil value)". Also how to access the PlayerGui with scripts? I am unsure of what this means and how to do this. I have tried rerouting it to StarterGUI and it works (I'm asking about this so I can learn).
1st Box
game.Players.PlayerAdded:Connect(function(player) wait(1) game.Players.player.Name.PlayerGui.EnterGui.TextLabel.Text = " " ..player.Name.. " has joined the game" wait(5) script.Parent.PlayerGui.EnterGUI.TextLabel.Text = " " end) --This is my code for Players
2nd Box: It does work for StarterGui but that brings me to my next problem. I want it to remove the message after a wait, as shown in the Second box of code below, and that doesn't work as well. No error code appears and I am unsure as to what is wrong. Can you help with this. Thanks!
2nd Box
game.Players.PlayerAdded:Connect(function(player) wait(1) game.StarterGui.EnterGui.TextLabel.Text = " " ..player.Name.. "has joined the game" wait(5) game.StarterGui.EnterGUI.TextLabel.Text = " " end) --This is my code for StarterGui
In your first code you did a mistake.
player
is not a valid member of game.Players, which makes it nil.
You don't use the name to access the children of the player
To fix this,
try typing this down in your first script
game.Players.PlayerAdded:Connect(function(player) wait(1) player.PlayerGui.EnterGui.TextLabel.Text = " " ..player.Name.. " has joined the game" wait(5) player.PlayerGui.EnterGUI:Destroy() end) --This is my code for Players
Hopefully this works, if not, please ask as many questions as you want
When using PlayerAdded, the player parameter takes the instance of the player already, so if you do game.Players.player, the script looks for someone named "player" in Players. What you want to do is actaully player.PlayerGui or game.Players:WaitForChild(player.Name), both of which work fine.
Secondly, you don't want to mess around with StarterGui too much, since that just changes the template that is applied to everyone when they either reset or first join the game. If you want to change the message, be sure to access PlayerGui instead of StarterGui, which applies to that specific player real-time.