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.

game.Players.PlayerAdded:Connect(function(player)
    local chatService = require(script.Parent:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

    local Speaker = chatService:AddSpeaker('New Player | ')
    Speaker:JoinChannel("All")
    Speaker:SayMessage(player.Name.." has joined the experience!")
end)

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

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

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

task.wait(0.5)
local remote = game.ReplicatedStorage.YourRemoteNameHere
remote.OnClientEvent:Connect(function(name)
game.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} )
end)

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

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

StarterGui Script

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

Answer this question