this script is supossed to add a chat tag to the owner of this gamepass and a chat color, the chatcolor works but theres no chattag, help?
local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)
local GAME_PASS_ID = 25754586
local VIP_TAGS = {
{
TagText = "đź‘‘VIP",
TagColor = Color3.new(0, 1, 1)
}
}
local function speakerAdded(speakerName)
local speaker = ChatService:GetSpeaker(speakerName)
local player = speaker:GetPlayer()
-- ChatSpeaker belongs to a player entity
if player then
local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, GAME_PASS_ID)
--local success, hasPass = true, true
if success and hasPass then
speaker:SetExtraData("Tags", VIP_TAGS)
speaker:SetExtraData("ChatColor", Color3.fromRGB(0, 226, 226))
end
end
end
ChatService.SpeakerAdded:Connect(speakerAdded)
for _, speaker in ipairs(ChatService:GetSpeakerList()) do
speakerAdded(speaker)
end
local gamepassId = 000000 -- Gamepass ID
local Players = game:GetService('Players')
local SSService = game:GetService('ServerScriptService')
local MPService = game:GetService("MarketplaceService")
local ChatService = require(SSService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
ChatService.SpeakerAdded:Connect(function(PlayerName)
local player = Players:FindFirstChild(PlayerName)
local hasPass
if player then
hasPass = MPService:UserOwnsGamePassAsync(player.UserId, gamepassId)
end
local Speaker = ChatService:GetSpeaker(PlayerName)
local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, GAME_PASS_ID)
--local success, hasPass = true, true
if success and hasPass then
-- Everything Below this line is customizable
Speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
Speaker:SetExtraData('ChatColor', Color3.fromRGB(0, 226, 226))
Speaker:SetExtraData('Tags', {{TagText = 'đź‘‘VIP', TagColor = Color3.fromRGB(0, 1, 1)}})
end
end)
Hello there! I tested your script by replacing if success and hasPass then by if true then and it works fine for me, so I assume the error is coming from the part where you are checking if the player owns the gamepass.
You redefined “hasPass” and then pcalled the MarketplaceService method, which errored as well because you passed a nil value for the gamepass ID (GAME_PASS_ID is not defined in your script)
local gamepassId = 000000 -- Gamepass ID
local Players = game:GetService('Players')
local SSService = game:GetService('ServerScriptService')
local MPService = game:GetService("MarketplaceService")
local ChatService = require(SSService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
ChatService.SpeakerAdded:Connect(function(PlayerName)
local player = Players:FindFirstChild(PlayerName)
local Speaker = ChatService:GetSpeaker(PlayerName)
local hasPass
if player then
hasPass = MPService:UserOwnsGamePassAsync(player.UserId, gamepassId)
end
local success, hasPass = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, gamepassId)
--local success, hasPass = true, true
if success and hasPass then
-- Everything Below this line is customizable
Speaker:SetExtraData('NameColor', Color3.fromRGB(255, 255, 255))
Speaker:SetExtraData('ChatColor', Color3.fromRGB(0, 226, 226))
Speaker:SetExtraData('Tags', {{TagText = 'đź‘‘VIP', TagColor = Color3.fromRGB(0, 1, 1)}})
end
end)