Chat tag trouble

Hello all!

So basically I am making an easter event for my game. Basically what I want is this:

On collide egg = chat message “player caught this egg”

I have been experimenting with different ways to use chat tags and watched some videos but never found a way to use it with a collide method.

I know I can use something like this

local plrs = game.Players
 
local sss = game.ServerScriptService
 
local chatService = require(sss:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
 
 
chatService.SpeakerAdded:Connect(function(plr)

    local speaker = chatService:GetSpeaker(plr)


	if plrs[plr].UserId == 212371943 then

        speaker:SetExtraData('NameColor', Color3.fromRGB(249, 166, 2))
        speaker:SetExtraData('ChatColor', Color3.fromRGB(124, 238, 255))
        speaker:SetExtraData('Tags', {{TagText = 'Developer', TagColor = Color3.fromRGB(33, 250, 250)}})

    end
end)

But I don’t know how to remix it.

Thanks.

1 Like

First you need to get the default channel by doing ChatService:GetChannel('All')

And send a system message with Channel:SendSystemMessage('content')

1 Like

How would I get the players name?

If you’re using collisions to detect when a player gets the egg, you can get the player from the character.

Currently I have this messy script


part = script.Parent

local function chat(message)
	game.StarterGui:SetCore("ChatMakeSystemMessage", {Text = message, Colour = Color3.fromRGB(255,255,255), Font = Enum.Font.ArialBold})
end

local messages = {"You got the egg of noob #1"} -- Replace Test Message with any text. To add more, put a comma after the " and put another in ""

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	-- if a humanoid exists, then
		chat(messages[math.random(1,#messages)])
	end 
end

script.Parent.Touched:connect(onTouch)

It obviously dosen’t work but i am confused as hell.

1 Like

ChatMakeSystemMessage
Only works on local scripts, if you’re going to use that, you can use remote events or use a server script and implement what @d_hq said.

Update: Still experimenting but I don’t know how to put the puzzle together.

1 Like

You can change your chat function to making a message with the method that @d_hq mentioned

1 Like

Yes but I don’t know how I would do that as im quite new to scripting.

1 Like
local sss = game.ServerScriptService
local Players = game:GetService("Players") 

local chatService = require(sss:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
part = script.Parent

local function chat(message)
	ChatService:GetChannel('All')
    Channel:SendSystemMessage("{System}: "message)
end

local messages = {"You got the egg of noob #1"} -- Replace Test Message with any text. To add more, put a comma after the " and put another in ""

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	-- if a humanoid exists, then
        local Plr = Players:GetPlayerFromCharacter(part.Parent)
		chat(Plr.Name..", got the egg of noob #1")
	end 
end

script.Parent.Touched:connect(onTouch)

Try this, it goes in a server script

Unknown global ‘Channel’ (Still confused.)

Expected ‘)’ (to close ‘(’ at column 27) got ‘message’ (Fixed with a comma.)

The script is a child of the part.

you can get the players name by doing

local Players = game:GetService("Players")

script.Parent.Touched:Connect(function(Hit)
	local Model = Hit:FindFirstAncestorOfClass("Model")
	if not Model then return end
	local Player = Players:GetPlayerFromCharacter(Model)
	if not Player then return end
	
	-- do stuff with player
end)
1 Like
local sss = game.ServerScriptService
local Players = game:GetService("Players") 

local chatService = require(sss:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
part = script.Parent

local function chat(message)
	local Channel = ChatService:GetChannel('All')
    Channel:SendSystemMessage("{System}: "message)
end

local messages = {"You got the egg of noob #1"} -- Replace Test Message with any text. To add more, put a comma after the " and put another in ""

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	-- if a humanoid exists, then
		chat(part.Parent.Name..", got the egg of noob #1")
	end 
end

script.Parent.Touched:connect(onTouch)

I jut realized a mistake I made, sorry. This script should work, it gets the player’s name from the character and says the player’s name in the chat and that they got the egg.

1 Like

Still got errors though

in chat function when you’re doing Channel:SendSystemMessage("{System}: "message), you should be doing Channel:SendSystemMessage("{System}: "..message)

and the ontouch function should look something like this

function onTouch(part) 
	local humanoid = part.Parent:FindFirstChild("Humanoid") 
	if (humanoid ~= nil) then	-- if a humanoid exists, then
		chat(part.Parent.Name..", got the egg of noob #1") -- or messages[math.random(1,#messages)]
	end 
end
2 Likes