How can I make this script say something like:
PvPNinjaDragon has joined the game!
I have a script that I believe that does this except it prints it in the Output. How can I make it so that it says it in the game chat?
01 | local Players = game:GetService( "Players" ) |
02 |
03 | function onPlayerAdded(player) |
04 | print (player.Name .. " has entered the game" ) |
05 | end |
06 |
07 | Players.PlayerAdded:connect(onPlayerAdded) |
08 |
09 | for _,player in pairs (Players::GetPlayers()) do |
10 | onPlayerAdded(player) |
11 | end |
Please help me, thank you.
1 | game.Players.PlayerAdded:Connect( function (player) |
The PlayerAdded
event just connects to the function whenever a player joines.
1 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { |
This just creates a SystemMessage
in the chat.
1 | Text = player.Name.. " has entered the game!" ; |
2 | Color = Color 3. new( 0 , 1 , 1 ); |
3 | Font = Enum.Font.SourceSansBold; |
4 | FontSize = Enum.FontSize.Size 24 |
5 | } ) |
6 | end ) |
These are just some variables
you can customise.
Full code:
01 | game.Players.PlayerAdded:Connect( function (player) |
02 |
03 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { |
04 | Text = player.Name.. " has entered the game!" ; |
05 | Color = Color 3. new( 0 , 1 , 1 ); |
06 | Font = Enum.Font.SourceSansBold; |
07 | FontSize = Enum.FontSize.Size 24 |
08 | } ) |
09 |
10 | end ) |
Remember to accept my answer if it helped and to leave a comment if you need further assistance, and to refer to this!