Hello , Is This Possible To Make A Accesory Only Chat Tag ?
Yeah, I forgot the code, will give it to you soon!
If you want to use LegacyChatService, check this
or if you want to use the new TextChatService, check this
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local CSR = ServerScriptService:WaitForChild("ChatServiceRunner", 5)
local ChatService = game:GetService("TextChatService")
if CSR ~= nil then -- checks if chat version is LegacyChatService or not
ChatService = require(CSR:WaitForChild("ChatService"))
else
ChatService = game:GetService("TextChatService")
end
local accessoryName = "" -- change this to name of accessory
local chatTag = "" -- change this to chat tag name
local tagColor = Color3.fromRGB(255, 255, 255) -- change this to chat tag color
if typeof(ChatService) == "Instance" and ChatService:IsA("TextChatService") then -- if chat version is TextChatService
ChatService.OnIncomingMessage = function(message)
local properties = Instance.new("TextChatMessageProperties")
if message.TextSource and message.TextSource.UserId > 0 then -- of message was sent by a player
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
local character = player.Character or player.CharacterAppearanceLoaded:Wait()
local accessory
for _, child in ipairs(character:GetChildren()) do
if child.Name == accessoryName and child:IsA("Accoutrement") then
accessory = child
end
end
if accessory then -- if player has the accessory on
properties.PrefixText = string.format("<font color='#%s'>[%s]</font> %s", tagColor:ToHex(), chatTag, message.PrefixText)
end
end
return properties
end
else -- if chat version is LegacyChatService
ChatService.SpeakerAdded:Connect(function(speakerName)
local speaker = ChatService:GetSpeaker(speakerName)
local player = speaker:GetPlayer()
if player then -- if speaker is a player
local character = player.Character or player.CharacterAppearanceLoaded:Wait()
local accessory
for _, child in ipairs(character:GetChildren()) do
if child.Name == accessoryName and child:IsA("Accoutrement") then
accessory = child
end
end
if accessory then -- if player has the accessory on
speaker:SetExtraData("Tags", {{TagText = chatTag, TagColor = tagColor}})
end
end
end)
end
I made this script that works for both LegacyChatService and TextChatService. All you gotta do is make a normal script in ServerScriptService, paste this code into the script, and change line 13-15 to whatever you desire.
If you want an explanation of the code, just check out the two links above the code.
i wrote this for almost an hour lol
I Changed The Accesory Name But It Doesnt Working For Me
Can you check the output window and see if there are any errors?
nvm i found out the error i made, copy and paste the code again and it should work
Oh wait, in the second to the last end at the very bottom, i forgot to add ) after end
so put it there
i also edited the code above so you can copy and paste again if you don’t get what i said above
I finally fixed (seriously this time, i even tried it in my game) my script 100%!!!
put this in normal script in ServerScriptService
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SetChatTag = ReplicatedStorage:WaitForChild("SetChatTag")
local ServerScriptService = game:GetService("ServerScriptService")
local CSR = ServerScriptService:WaitForChild("ChatServiceRunner", 5)
local ChatService = game:GetService("TextChatService")
if CSR ~= nil then -- checks if chat version is LegacyChatService or not
ChatService = require(CSR:WaitForChild("ChatService"))
else
ChatService = game:GetService("TextChatService")
end
local accessoryName = "" -- change this to name of accessory
local chatTag = "" -- change this to chat tag name
local tagColor = Color3.fromRGB(255, 255, 255) -- change this to chat tag color
if typeof(ChatService) == "Instance" and ChatService:IsA("TextChatService") then -- if chat version is TextChatService
local function onPlayerAdded(player: Player)
SetChatTag:FireClient(player, accessoryName, chatTag, tagColor)
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(onPlayerAdded, player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
else -- if chat version is LegacyChatService
local function onSpeakerAdded(speakerName: string)
local speaker = ChatService:GetSpeaker(speakerName)
local player: Player? = speaker:GetPlayer()
if player then -- if speaker is a player
local character = player.Character or player.CharacterAppearanceLoaded:Wait()
local accessory
for _, child in ipairs(character:GetChildren()) do
if child.Name == accessoryName and child:IsA("Accoutrement") then
accessory = child
end
end
if accessory then -- if player has the accessory on
speaker:SetExtraData("Tags", {{TagText = chatTag, TagColor = tagColor}})
end
end
end
for _, channelName: string in ipairs(ChatService:GetChannelList()) do
task.spawn(function()
local channel = ChatService:GetChannel(channelName)
if channel then
for _, speakerName: string in ipairs(channel:GetSpeakerList()) do
task.spawn(onSpeakerAdded, speakerName)
end
end
end)
end
ChatService.SpeakerAdded:Connect(onSpeakerAdded)
end
after that, create a RemoteEvent in ReplicatedStorage then name it “SetChatTag”
and lastly, make a LocalScript in StarterPlayer → StarterPlayerScripts and put this
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SetChatTag = ReplicatedStorage:WaitForChild("SetChatTag")
SetChatTag.OnClientEvent:Connect(function(accessoryName: string, chatTag: string, tagColor: Color3)
TextChatService.OnIncomingMessage = function(message)
local properties = Instance.new("TextChatMessageProperties")
if message.TextSource and message.TextSource.UserId > 0 then -- if message was sent by a player
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
local character = player.Character or player.CharacterAppearanceLoaded:Wait()
local accessory
for _, child in ipairs(character:GetChildren()) do
if child.Name == accessoryName and child:IsA("Accoutrement") then
accessory = child
end
end
if accessory then -- if player has the accessory on
properties.PrefixText = string.format("<font color='#%s'>[%s]</font> %s", tagColor:ToHex(), chatTag, message.PrefixText)
end
end
return properties
end
end)
this should finally solve your problems for the past 8 days
Thank You So Much , It Works !
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.