How to make a script where when a player obtains a badge, it sends a system chat announcing that the player has obtained a badge?

Hi, I’v tried to make it so every time that someone obtains a badge, a system message is sent in the chat but the issue is I don’t know how to send RemoteEvents. I did look at other forum pages but It was too complicated for me to understand. I did try to run it in a server script before I learned how it worked and it didn’t work so if someone could help me make a local script (for firing the RemoteEvent once a player obtained the badge which sends the info of the badge and the player) and a server script (for receiving the RemoteEvent and put the info in chat) for me to use, I’d appreciate it.

Id also wanna know how RemoteEvent works with simple explanations so I could learn myself how to do it.

1 Like

You would have to fire a function that sends the message every time you award a player with a badge.

I know but it’s just I don’t really know how to send functions. I feel like the Roblox Developer website would explain it in a complicated way which I might not understand properly.

Step1: Make RemoteEvent Called ‘SendChatRemote’ in a ReplicatedStorage.

Step2: Make LocalScript in StarterGui. And put this code:

game.ReplicatedStorage.SendChatRemote.OnClientEvent:Connect(function(data)
		game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", data)
end)

Step3: Go to the script that award badge to player.

insert this code after award badge.

game.ReplicatedStorage.SendChatRemote:FireAllClients({
			Text = (PlayerNameHere .. " got [BADGENAME] Badge!!"); --The chat message
			Color = Color3.fromRGB(206, 165, 255); --Chat message color, defaults to white
			Font = Enum.Font.SourceSansBold; --Chat message font, defaults to SourceSansBold
			TextSize = 18 --Text size, defaults to 18
		})
4 Likes

Followed your steps, outputs an error.

sorry I edited now please change local script! Sorry!

You just have to change the LocalScript like:

game.ReplicatedStorage.SendChatRemote.OnClientEvent:Connect(function(data)
		game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", data)
end)

Yeah, I knew how to change it. Looks like another error popped out however.


This one is in the server script. I’v put it after the badge reward like you said.

You made a RemoteFunction, you have to add a RemoteEvent.

right Not a ‘RemoteFunction’.It’s ‘RemoteEvent’

Oh whoops. My bad. Let me fix it.

u dont need clients to send a message

--server
game.StarterGui:SetCore("ChatMakeSystemMessage", data)

You forgot to add a " at the end

oof, I made a mistake in LocalScript.
Change Local Script to:

game.ReplicatedStorage.SendChatRemote.OnClientEvent:Connect(function(data)
		game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", data)
end)

You saw nothing

thanks for reminding me though

If you make chat in server we can’t send message to specified players.

Amazing timing I made a huge explanation on client, server and RemoteEvents yesterday. Here’s the post

Haha, commit you’re always funny. And, you’re welcome!

But we want it to send to all clients. So its not nessecary now.

Awesome! Thanks. Ill read it later.

1 Like

We can make server message toggle button if we make chat at client.