Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Print PlayerAdded:connect in chat?

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?

local Players = game:GetService("Players")
	
function onPlayerAdded(player)
	print(player.Name .. " has entered the game")
end

Players.PlayerAdded:connect(onPlayerAdded)

for _,player in pairs(Players::GetPlayers()) do
	onPlayerAdded(player)
end

Please help me, thank you.

2 comments

0

It's not possible to do this with Roblox's normal chat system. You can either use a Gui or custom chat system.

0

Yes, it is possible. One second.

1 answer

✓ Accepted answer
game.Players.PlayerAdded:Connect(function(player)

The PlayerAdded event just connects to the function whenever a player joines.

game.StarterGui:SetCore("ChatMakeSystemMessage", {

This just creates a SystemMessage in the chat.

	Text = player.Name.." has entered the game!";
	Color = Color3.new(0, 1, 1);
	Font = Enum.Font.SourceSansBold;
	FontSize = Enum.FontSize.Size24
})
end)

These are just some variables you can customise.

Full code:

game.Players.PlayerAdded:Connect(function(player)

game.StarterGui:SetCore("ChatMakeSystemMessage", {
	Text = player.Name.." has entered the game!";
	Color = Color3.new(0, 1, 1);
	Font = Enum.Font.SourceSansBold;
	FontSize = Enum.FontSize.Size24
})

end)

Remember to accept my answer if it helped and to leave a comment if you need further assistance, and to refer to this!

1 comment

0

Doesn't seem to work when I actually play the game. But I does work when I test it in studio in play mode.

This discussion is preserved as it was. New answers, comments, and votes are closed.