VIP Tag gets granted to everyone

Hello, so I have a script but instead of it getting granted to people with VIP gamepass it gets granted to everyone. How do I fix this?

Code

local textChatService = game:GetService("TextChatService")
local MPC = game:GetService("MarketplaceService")

textChatService.OnIncomingMessage = function(message: TextChatMessage)

	local properties = Instance.new("TextChatMessageProperties")

	if message.TextSource then

		local player = game:GetService("Players"):GetPlayerByUserId(message.TextSource.UserId)
		local LocalPlay = game.Players.LocalPlayer

		if player.Name == "YoGurl_Lexi4" or player.Name == "IconicDivinee" or player.Name == "hellouhwhatismyname" or player.Name == "Elcryic" or player.Name == "ChaseHooo" or player.Name == "Advertiesed" or player.Name == "Dnmjdmes" or player.Name == "ASQSZS" or player.Name == "Sirgime" then

			properties.PrefixText = "<font color='#096e09'>[Beta Tester]</font> " .. message.PrefixText
			
		elseif player.Name == "5Flipz" then
			
			properties.PrefixText = "<font color='#000000'>[Founder]</font> " .. message.PrefixText
			
		elseif player.Name == "LOLXD_rob" or player.Name == "6ni_nog" or player.Name == "46io" then
			
			properties.PrefixText = "<font color='#bc2424'>[]</font> " .. message.PrefixText
			
		elseif player.Name == "bullnance555" or player.Name == "S1rDxvin" then

			properties.PrefixText = "<font color='#d72f7f'>[Influencer]</font> " .. message.PrefixText
			
		elseif MPC:UserOwnsGamePassAsync(LocalPlay.UserId, 180164478) then

			properties.PrefixText = "<font color='#ffd700'>[VIP]</font> " .. message.PrefixText
		end

	end

	return properties

end
2 Likes

Try replacing

with player, so the line should be like this,

		elseif MPC:UserOwnsGamePassAsync(player.UserId, 180164478) then


1 Like

I got this error Error occurred while calling TextChatService.OnIncomingMessage: MarketPlace:UserOwnsGamePassAsync() can only query local player

1 Like

Can you show me the updated script with a screenshot of the error?

1 Like

Update Script

local textChatService = game:GetService("TextChatService")
local MPC = game:GetService("MarketplaceService")

textChatService.OnIncomingMessage = function(message: TextChatMessage)

	local properties = Instance.new("TextChatMessageProperties")

	if message.TextSource then

		local player = game:GetService("Players"):GetPlayerByUserId(message.TextSource.UserId)

		if player.Name == "YoGurl_Lexi4" or player.Name == "IconicDivinee" or player.Name == "hellouhwhatismyname" or player.Name == "Elcryic" or player.Name == "ChaseHooo" or player.Name == "Advertiesed" or player.Name == "Dnmjdmes" or player.Name == "ASQSZS" or player.Name == "Sirgime" then

			properties.PrefixText = "<font color='#096e09'>[Beta Tester]</font> " .. message.PrefixText
			
		elseif player.Name == "5Flipz" then
			
			properties.PrefixText = "<font color='#000000'>[Founder]</font> " .. message.PrefixText
			
		elseif player.Name == "LOLXD_rob" or player.Name == "6ni_nog" or player.Name == "46io" then
			
			properties.PrefixText = "<font color='#bc2424'>[]</font> " .. message.PrefixText
			
		elseif player.Name == "bullnance555" or player.Name == "S1rDxvin" then

			properties.PrefixText = "<font color='#d72f7f'>[Influencer]</font> " .. message.PrefixText
			
		elseif MPC:UserOwnsGamePassAsync(player.UserId, 180164478) then

			properties.PrefixText = "<font color='#ffd700'>[VIP]</font> " .. message.PrefixText
		end

	end

	return properties

end

image
This error occurred when a user typed in chat

1 Like

I think this means that only the client can check using marketplace service, try using a remote event from the server to the client to see if they own the gamepass.

Also where did you get this variable from, I don’t see it in your script.

1 Like

I removed that to make it the local players or something like that

1 Like

Alright, try this method then and tell me what happens.

How would I do that with the if statement?

1 Like

You can fire a event to a local script and then check for the gamepass, then fire a event back to the server with a variable added on that could be true or false, if its true then give them the chat color, if not ignore it.

Local script:

remoteevent:Connect(function()
   if playerhasgamepass then
        remoteevent:FireServer(true)
   end
end)

ServerScript:

remoteevent:FireClient(player)
remoteevent:Connect(function(plr, value)
       if value == true then
               properties.PrefixText = "<font color='#ffd700'>[VIP]</font> " .. message.PrefixText
       end
end)

My chat tag script is a local script so wouldnt those 2 switch?

1 Like

Wait its a local script? Oh then my bad, try replacing

with game.Players.LocalPlayer then

So just

local textChatService = game:GetService("TextChatService")
local MPC = game:GetService("MarketplaceService")

textChatService.OnIncomingMessage = function(message: TextChatMessage)

	local properties = Instance.new("TextChatMessageProperties")

	if message.TextSource then

		local player = game:GetService("Players"):GetPlayerByUserId(message.TextSource.UserId)

		if player.Name == "YoGurl_Lexi4" or player.Name == "IconicDivinee" or player.Name == "hellouhwhatismyname" or player.Name == "Elcryic" or player.Name == "ChaseHooo" or player.Name == "Advertiesed" or player.Name == "Dnmjdmes" or player.Name == "ASQSZS" or player.Name == "Sirgime" then

			properties.PrefixText = "<font color='#096e09'>[Beta Tester]</font> " .. message.PrefixText
			
		elseif player.Name == "5Flipz" then
			
			properties.PrefixText = "<font color='#000000'>[Founder]</font> " .. message.PrefixText
			
		elseif player.Name == "LOLXD_rob" or player.Name == "6ni_nog" or player.Name == "46io" then
			
			properties.PrefixText = "<font color='#bc2424'>[]</font> " .. message.PrefixText
			
		elseif player.Name == "bullnance555" or player.Name == "S1rDxvin" then

			properties.PrefixText = "<font color='#d72f7f'>[Influencer]</font> " .. message.PrefixText
			
		elseif MPC:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, 180164478) then

			properties.PrefixText = "<font color='#ffd700'>[VIP]</font> " .. message.PrefixText
		end

	end

	return properties

end
1 Like

Yes, try this and tell me the result.

I did before but it gave everyone the Chat tag

1 Like

Are you testing it in roblox studio? Try testing it in the roblox player in a account without the gamepass.

I tested it in a server with quite a few people and it gave everyone the Tag idky

1 Like

Roblox Studio team test or in the roblox player server.

The Roblox player server. Not sure why it doesnt work