Gamepass Chat Tag Issue

Hi everyone,
I’m a builder but I have a basic understanding of Lua. I’m trying to create a chat tag for those who purchase my game pass, so they will have a “Premium” label right next to their username in the chatbox. The problem is, it’s not showing up.
Screen Shot 2020-06-21 at 4.08.50 PM
The following script isn’t working, the output isn’t showing any errors and the “Go to Script Error” button is blanked out.

local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 10304252
local ChatService = require{ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService")}
local Players = game:GetService("Players")

ChatService.SpeakerAdded:Connect(function(plrname)
	local Speaker = ChatService:GetSpeaker{plrname}
	if MarketplaceService:UserOwnsGamePassAsync(Players[plrname].UserId, gamepassId) then
		Speaker:SetExtraData('Tags', {{TagText = "Premium", TagColor = Color3.fromRGB(253,89,84)}})
	end
end)

The only thing I’ve tried so far is adding spaces between the commas, but I know that’s not gonna do anything. I’m not sure what to do, since I found this on a YouTube tutorial.

If you see an error, please let me know! Thanks.

You are passing a reference to a table. require expects a module script or an ID of one, not a table. Remember that

a"b"
a{ ... }

is syntatic sugar for

a("b")
a({ ... })

Parentheses in function calls can be omitted if a single string or table literal is passed. Simply use parentheses instead of curly braces.

You do this here as well.

2 Likes

I have gone ahead and got this script that had made. I hope this helps and it says how to use it.

 -- This is a vip chat I created.

local MarketplaceService = game:GetService(“MarketplaceService”)
local GamepassID = 000000 – Change ‘000000’ to your Gamepass ID

game.Players.PlayerAdded:Connect(function(Player) --When player join in game
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, GamepassID) then – If player have gamepass…
local tags = {
{
TagText = “VIP”, – Tag Name, You can change to whatever you like
TagColor = Color3.fromRGB(255, 255, 0) – Tag Color, You can change to color you like
}
}
local ChatService = require(game:GetService(“ServerScriptService”):WaitForChild(“ChatServiceRunner”).ChatService) – Requires ChatService
local speaker = nil – speaker is nil
while speaker == nil do – While speaker is nil do…
speaker = ChatService:GetSpeaker(Player.Name) – Get speaker from player
if speaker ~= nil then
break – If speaker is nil then break
end
wait(0.01) – wait
end
speaker:SetExtraData(“Tags”,tags) – Set tags
speaker:SetExtraData(“ChatColor”,Color3.fromRGB(255, 255, 0)) – Chat Color, You can change to color you like
end
end)

1 Like

I tried your script but I keep on getting this error.

Screen Shot 2020-06-21 at 4.38.40 PM

Could something have gone wrong?

Line 17 for the script (in my POV) is:

 game.Players.PlayerAdded:Connect(function(Player)

Make sure the end statement that pairs to that is “end)”, not “end”

1 Like

Line one is “” not the ones there there!

Line two “to your Gamepass ID” there is no – brecks everything!

You always have " but into the text!

You forget the – in every line there is a text!!!

Here is the fix!

local gamepassId = 123456789–Gamepass here!
local service = game:GetService(“MarketplaceService”)
game.Players.PlayerAdded:Connect(function(player)
if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
local tags = {
{
TagText = “Premium”,–Tag here!
TagColor = Color3.fromRGB(255, 0, 4)–Tag color!
}
}
local ChatService = require(game:GetService(“ServerScriptService”):WaitForChild(“ChatServiceRunner”).ChatService)
local speaker = nil
while speaker == nil do
speaker = ChatService:GetSpeaker(player.Name)
if speaker ~= nil then break end
wait(0.01)
end
speaker:SetExtraData(“Tags”,tags)
speaker:SetExtraData(“NameColor”,Color3.fromRGB(255, 0, 4))–Change NameColor to ChatColor NameColor Is the name like mine raulgamer43 and ChatColot Is What i say!
end
end)

Sorry send it to the wrong person!

local gamepassId = 123456789--Gamepass here!
local service = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
		local tags = {
			{
				TagText = "Premium",--Tag here!
				TagColor = Color3.fromRGB(255, 0, 4)--Tag color!
			}
		}
		local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
		local speaker = nil
		while speaker == nil do
			speaker = ChatService:GetSpeaker(player.Name)
			if speaker ~= nil then break end
			wait(0.01)
		end
		speaker:SetExtraData("Tags",tags)
		speaker:SetExtraData("NameColor",Color3.fromRGB(255, 0, 4))--Change NameColor to ChatColor NameColor Is the name like mine raulgamer43 and ChatColot Is What i say!
	end
end)