Heyo,
This script has a race-condition in it. Your first line game.Workspace:WaitForChild("Console")
will block execution of the rest of your script until the object is loaded, or a timeout is reached.
This means that it is possible that a player could join the game before the script can listen for the game.Players.PlayerAdded
signal.
Also StarterGui does not exist on specific player. It exists at the game level and is a bucket that dumps its stuff into a Player's PlayerGui when that player's character loads into the game.
So to fix your script, you could try something like this :
-- right away connect to the PlayerAdded signal
game.Players.PlayerAdded:Connect(function(plr)
print("Player Joined!", plr.Name, plr.UserId)
-- do something special if wojciechpa2007 joins
if plr.Name == "wojciechpa2007" then
print("wojciechpa2007 joined! Adding console!")
-- add the special console into the player's PlayerGui for when they load
local Console = game.Lighting.Console:Clone()
Console.Parent = plr.PlayerGui
end
end)
Some recommendations and things to be careful about here :
- It's safer to check a player's UserId than it is to check their name. Roblox lets you change your name, but you UserId is always the same.
- Putting something into your StarterGui will make it show up in your PlayerGui the next time your character loads. But if your character is already loaded, you won't see it until the next time you respawn.
- If your Console object is some kind of GUI element, make sure that it is parented to a ScreenGui object before you insert it into the Player. Otherwise it just won't show up.
Hope this helps!