My question is very simple. Whenever I (the admin) of the game join, I the want the server to write the message in the chatbox "The Admin Has Joined The Game".
1st Step
I tried to make a simple ChatMakeSystemMessage inside StarterPlayer --> StarterPlayerScripts --> LocalScript.
Inside the local script, I first tried to do the below code. All this below code does is that is writes on the chatbox "The Admin has joined the game" whenever the server starts. Which I don't want.
game.StarterGui:SetCore("ChatMakeSystemMessage", { Text = "The Admin Has Joined The Game"; Font = Enum.Font.Cartoon; FontSize = Enum.FontSize.Size24 })
2nd Step
So now I tried to make a PlayerAdded Event inside the LocalScript, and simply checked if the player who joined, if their name was "Soban06" (which is me). And if that was the case, we would write "The Admin Has Joined The Game". Else, we wouldn't do anything.
So here is my code with the PlayerAdded Event:
game.Players.PlayerAdded:Connect(function(Player) if Player.Name == "Soban06" then game.StarterGui:SetCore("ChatMakeSystemMessage", { Text = "The Admin Has Joined The Game"; Font = Enum.Font.Cartoon; FontSize = Enum.FontSize.Size24 }) end end)
But when I do the above, nothing happens when I join the game. I am perfectly sure that when I join the game, my name on the leader board is the same as the one I mentioned in the script.
But nothing happens.
Please assist me in this.
Thanks
Like k3du53 said, it won't actually fire for yourself. My solution constantly loops through over and over again to see if players got missed.
local Players = game:GetService("Players") local StarterGui = game:GetService("StarterGui") local SentMessage = false local function AdminMessage(Player) if Player.UserId == 617445798 and not SentMessage then StarterGui:SetCore("ChatMakeSystemMessage", {Text="{System} Admin has joined the game"}) SentMessage = true end end local function LoopThroughPlayers() while true do for Index, Player in pairs(Players:GetChildren()) do if Player.UserId == 617445798 and not SentMessage then StarterGui:SetCore("ChatMakeSystemMessage", {Text="{System} An admin has joined the game"}) SentMessage = true end end wait() end end Players.PlayerAdded:Connect(AdminMessage) spawn(LoopThroughPlayers)
The game.Players.PlayerAdded
event won't fire for yourself in a LocalScript, because you join the game before that script runs.
A potential solution would be to loop through the players and display the message if they exist.
ex.
game.Players.PlayerAdded:Connect(function(Player) if Player.Name == "Soban06" then game.StarterGui:SetCore("ChatMakeSystemMessage", { Text = "The Admin Has Joined The Game"; Font = Enum.Font.Cartoon; FontSize = Enum.FontSize.Size24 }) end end) for i,player in pairs(game.Players:GetPlayers()) do if player.Name == "Soban06" -- "The admin is in this game!" or something end end