local Event = game.ReplicatedStorage["Arrest/Bounty"].Arrest
local chat = game:GetService("TextChatService")
local channel = chat:WaitForChild("TextChannels"):WaitForChild("RBXSystem")
local function generateSystemMsg(MsgDict: array)
return '<font color="#'..MsgDict["Color"]..'"><font size="'..MsgDict["FontSize"]..'"><font face="'..MsgDict["Font"]..'">'..MsgDict["Text"]..'</font></font></font>'
end
Event.OnClientEvent:Connect(function(player,target,Bounty,Type)
wait(1)
channel:DisplaySystemMessage(
generateSystemMsg({
Text = "{Server}"..player.Name.." Has Collected "..target.Name.. "'s Bounty of "..Bounty;
Font = "FredokaOne";
Color = Color3.fromRGB(14, 235, 255):ToHex();
FontSize = "15";
})
)
end)
if anyone could explain why I’m getting this error, as the robbery messages work fine with the same code
Rob.OnClientEvent:Connect(function(plr,Robbery,types,Ammount)
print(plr.Name,Robbery,Ammount)
wait(1)
channel:DisplaySystemMessage(
generateSystemMsg({
Text = "{Server} "..plr.Name.." Has Robbed the "..Robbery.." for $"..Comma(Ammount);
Font = "FredokaOne";
Color = Color3.fromRGB(255, 36, 28):ToHex();
FontSize = "15";
})
)
end)
This error I think is called when the script is destroyed (deleted). Does any other scripts or further in the code the script deletes itself or deletes early?
I think you probably have another code that is messing with the chat, because I tested the code and it works perfectly fine, at least the ones you provided.
local function GenerateChatTag(text: string, colour: Color3):string
return '<font color="'..colour..'"><font size="17"><font face="FredokaOne">'..text..'</font></font></font>'
end
local Players = game:GetService("Players")
local ChatTextService = game:GetService("TextChatService")
local groupId = 8713381
ChatTextService.OnIncomingMessage = function (message: TextChatMessage)
local Properties = Instance.new("TextChatMessageProperties")
Properties.Text = "<font size='17'><font face='FredokaOne'>"..message.Text.."</font></font>"
if message.TextSource then
local Player = Players:GetPlayerByUserId(message.TextSource.UserId)
local GroupRank = Player:GetRoleInGroup(groupId)
Properties.PrefixText = GenerateChatTag("["..GroupRank.."] ["..message.PrefixText.."]","#1ab7e7")
end
return Properties
end