Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I send in a message in the roblox chat when a player joins?

Asked by 2 years ago
Edited 2 years ago

So I've been trying to make it where when a player joins, it sends a message to the whole server saying, > Player.Name has joined the Experience! < but my script doesn't work, can anyone help me? I have been using ChatService.

I have it in ServerScriptService.

1game.Players.PlayerAdded:Connect(function(player)
2    local chatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
3 
4    local Speaker = chatService:AddSpeaker('New Player | ')
5    Speaker:JoinChannel("All")
6    Speaker:SayMessage(player.Name.." has joined the experience!")
7end)

2 answers

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You can use StarterGui:SetCore("ChatMakeSystemMessage") https://developer.roblox.com/en-us/api-reference/function/StarterGui/SetCore

1: Make a remote event in ReplicatedStorage name it what ever you want

2: Make a script in ServerScriptService and write the code below

1local remote = game.ReplicatedStorage.YourRemoteNameHere
2game.Players.PlayerAdded:Connect(function(player)
3remote:FireAllClients(player.Name)
4end)

3: Make a local script in StarterPlayerScripts and write the following:

1task.wait(0.5)
2local remote = game.ReplicatedStorage.YourRemoteNameHere
3remote.OnClientEvent:Connect(function(name)
4game.StarterGui:SetCore( "ChatMakeSystemMessage"{ Text = "[System] "..name.." has joined the experience say hi!" , Color = Color3.new( 1,1,1 ), Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size14} )
5end)

4: Enjoy

Sorry if i made any mistakes i wrote this on mobile

0
Hi, there is a problem with that. I want it to send it to the entire server, not just the client. Joint_Ventures 5 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

I solved it. I am posting it here for others:

Create a RemoteEvent and name it, "Joined"

Create a Script in ServerScriptService and name it whatever you would like.

Create a LocalScript in StarterGui and name it whatever you would like.

ServerScriptService Script

1game.Players.PlayerAdded:Connect(function(player)
2    game.ReplicatedStorage.Joined:FireAllClients(player.Name)
3end)

StarterGui Script

1game.ReplicatedStorage.Joined.OnClientEvent:Connect(function(playerName)
2    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{
3        Text = "New Player Joined | "..playerName.." has joined the experience!";
4        Font = Enum.Font.SciFi; -- Customizable
5        FontSize = Enum.FontSize.Size18; -- Customizable
6        Color = Color3.fromRGB(0,0,255) -- Customizable
7    })
8end)

Answer this question