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.
1 | game.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!" ) |
7 | end ) |
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
1 | local remote = game.ReplicatedStorage.YourRemoteNameHere |
2 | game.Players.PlayerAdded:Connect( function (player) |
3 | remote:FireAllClients(player.Name) |
4 | end ) |
3: Make a local script in StarterPlayerScripts and write the following:
1 | task.wait( 0.5 ) |
2 | local remote = game.ReplicatedStorage.YourRemoteNameHere |
3 | remote.OnClientEvent:Connect( function (name) |
4 | game.StarterGui:SetCore( "ChatMakeSystemMessage" , { Text = "[System] " ..name.. " has joined the experience say hi!" , Color = Color 3. new( 1 , 1 , 1 ), Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size 14 } ) |
5 | end ) |
4: Enjoy
Sorry if i made any mistakes i wrote this on mobile
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
1 | game.Players.PlayerAdded:Connect( function (player) |
2 | game.ReplicatedStorage.Joined:FireAllClients(player.Name) |
3 | end ) |
StarterGui Script
1 | game.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.Size 18 ; -- Customizable |
6 | Color = Color 3. fromRGB( 0 , 0 , 255 ) -- Customizable |
7 | } ) |
8 | end ) |