Roblox Chat Tag Script Support(FIXED)

hi,
i am trying to make a multi tag script but when i always try to start the game i always get the same error , if anyone know how to fix will be glad to get some help


here is the script,

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local Players = game.Players
local users = {
	-- ["Username"] = {"UserID", "Vip?", "Booster?", "Helper?", "Admin?", "Dev?"}
	["godenotfan007"] 	  = {"239345228", true, true, true, false, true},
	--["username"] = {"userid", false, false, false, false, false, false},
}

local function applyTagsToSpeaker(speaker)
	local speakerName = speaker.Name
	local player = Players:FindFirstChild(speakerName)
	if player then
		local userId = player.UserId
		local user = users[player.Name]
		if user and user[2] == userId then
			local tags = {}
			if user[6] or user[7] then
				table.insert(tags, {TagText = "Staff", TagColor = Color3.fromRGB(255, 255, 0), TagFont = Enum.Font.Cartoon})
			end
			if user[3] then
				table.insert(tags, {TagText = "Vip", TagColor = Color3.fromRGB(255, 255, 0), TagFont = Enum.Font.Cartoon})
			end
			if user[4] then
				table.insert(tags, {TagText = "Booster", TagColor = Color3.fromRGB(255, 192, 203), TagFont = Enum.Font.Cartoon})
			end
			if user[5] then
				table.insert(tags, {TagText = "Helper", TagColor = Color3.fromRGB(44, 255, 213), TagFont = Enum.Font.Cartoon})
			end
			if user[6] then
				table.insert(tags, {TagText = "Admin", TagColor = Color3.fromRGB(26, 29, 255), TagFont = Enum.Font.Cartoon})
			end
			if user[7] then
				table.insert(tags, {TagText = "Dev", TagColor = Color3.fromRGB(163, 58, 255), TagFont = Enum.Font.Cartoon})
			end
			speaker:SetExtraData("Tags", tags)
		end
	end
end

local function applyTagsToAllSpeakers()
	for _, speaker in ipairs(ChatService:GetSpeakerList()) do
		applyTagsToSpeaker(speaker)
	end
end

ChatService.SpeakerAdded:Connect(function(speaker)
	applyTagsToSpeaker(speaker)
end)

applyTagsToAllSpeakers()
4 Likes

Haven’t dealt with it in a while, but if I remember correctly, SpeakerAdded gives the parameter of speakername, NOT speaker.

This means that you are then trying to get the name of a string (which returns nil), which in turns causes the Players:FindFirstChild() to error with Argument 1 missing or nil.

Try replacing

local function applyTagsToSpeaker(speaker)
	local speakerName = speaker.Name

with

local function applyTagsToSpeaker(speakerName)

and see if it resolves your issue

1 Like

hello, i have tried as you told but it haven’t fixed it,
it has given no error too

1 Like

Can you please add print statements in the following locations:

  • After if player then
  • After if user and user[2] == userId

and let me know whether both of the print statements are fired

1 Like

added the prints but only the first worked
image
image

1 Like

Before the second if statement, can you please add:

  • print(user)
  • print(user[2], userId
  • print(user[2] == userId)
1 Like

image
bet i forgot to tell but i changed the

		if user and user[2] == userId then

too

		if user and user[1] == userId then

so the

print(user)
print(user[1], userId
print(user[1] == userId)

tell this
image

1 Like

when functions are called, you can use parameters just the same.

local function touched(ABCFG)
    if ABCFG and ABCFG.Parent:FindFirstChild("Humanoid") then
       ABCFG.Parent.Humanoid.Health = 0
    end
end

script.Parent.Touched:Connect(touched)

--will still work
1 Like

in

["godenotfan007"] 	  = {"239345228", true, true, true, false, true},

if you make the userId a number instead of a string

["godenotfan007"] 	  = {239345228, true, true, true, false, true},

does it work?

2 Likes

got this issue


the script right now :

local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
local Players = game.Players
local users = {
	-- ["Username"] = {"UserID", "Vip?", "Booster?", "Helper?", "Admin?", "Dev?"}
	["godenotfan007"] 	  = {239345228, true, true, true, false, true},
	--["username"] = {"userid", false, false, false, false, false, false},
}

local function applyTagsToSpeaker(speakerName)
	local player = Players:FindFirstChild(speakerName)
	if player then
		print("player found")
		local userId = player.UserId
		local user = users[player.Name]
		print(user)
		print(user[1], userId)
		print(user[1] == userId)
		if user and user[1] == userId then
			print("Player Found and ID exist in the whitelist")
			local tags = {}
			if user[6] or user[7] then
				table.insert(tags, {TagText = "Staff", TagColor = Color3.fromRGB(255, 255, 0), TagFont = Enum.Font.Cartoon})
			end
			if user[3] then
				table.insert(tags, {TagText = "Vip", TagColor = Color3.fromRGB(255, 255, 0), TagFont = Enum.Font.Cartoon})
			end
			if user[4] then
				table.insert(tags, {TagText = "Booster", TagColor = Color3.fromRGB(255, 192, 203), TagFont = Enum.Font.Cartoon})
			end
			if user[5] then
				table.insert(tags, {TagText = "Helper", TagColor = Color3.fromRGB(44, 255, 213), TagFont = Enum.Font.Cartoon})
			end
			if user[6] then
				table.insert(tags, {TagText = "Admin", TagColor = Color3.fromRGB(26, 29, 255), TagFont = Enum.Font.Cartoon})
			end
			if user[7] then
				table.insert(tags, {TagText = "Dev", TagColor = Color3.fromRGB(163, 58, 255), TagFont = Enum.Font.Cartoon})
			end
			speakerName:SetExtraData("Tags", tags)
		end
	end
end

local function applyTagsToAllSpeakers()
	for _, speaker in ipairs(ChatService:GetSpeakerList()) do
		applyTagsToSpeaker(speaker)
	end
end

ChatService.SpeakerAdded:Connect(function(speaker)
	applyTagsToSpeaker(speaker)
end)

applyTagsToAllSpeakers()
1 Like

just to advertise that i found the issue in was on

ChatService.SpeakerAdded:Connect(function(speaker)
	applyTagsToSpeaker(speaker)
end)

too


ChatService.SpeakerAdded:Connect(function(speakerName)
	local speaker = ChatService:GetSpeaker(speakerName)
	if speaker then
		applyTagsToSpeaker(speaker)
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.