i have problem i wanna check if player owns gamepass and if he owns give player nametag(prefix) in chat, code dont throw errors but it didnt work as expected
local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gpId = 1013492658
local chat = game:GetService("TextChatService")
--local tags = {[0] = {TagText = "TUTORIAL", TagColor = Color3.fromRGB(255, 0, 0)},}
local MarketplaceService = game:GetService("MarketplaceService")
local function checkGamePass(player)
local success, result = pcall(MarketplaceService.UserOwnsGamePassAsync, MarketplaceService, player.UserId, gpId)
if success then
if result then
print("owns Game Pass")
chat.OnIncomingMessage = function(message: TextChatMessage)
local properties = Instance.new("TextChatMessageProperties")
if message.TextSource then
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
properties.PrefixText = "<font color='#9a3e3e'>[Supporter]</font> " .. message.PrefixText
end
return properties
end
end
else
print("does not own Game Pass")
end
end
for _, player in ipairs(Players:GetPlayers()) do
checkGamePass(player)
end
Players.PlayerAdded:Connect(checkGamePass)
its not displayed at all : for more detailed description i can say text is white above player head created buble with text but in chat only player nickname and message(no errors in output and even print statement)
I think the reason of nametag doesn’t display is it only considers the case of successful possession of the game pass and does not consider the case of failure. How about adding code to retry in case of failure? I tested the code you provided with delete game pass check code, and it runs successfully.
And also, if you can’t solve the problem although if you did what I said, please check the script class is LocalScript and its parent is StarterPlayerScripts. it may occur error when its parent is StarterCharacterScripts or else.