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
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
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.
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)
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