Simple coding Support, gamepass script

Hello! Thank you if you decide to help as I am not good at scripting and I dont know how to solve this problem.
So I have this script in my game that when a player joins and they own the VIP gamepass, they receive a chat tag: [VIP].
The problem is I also have a chat tag for the owner (me), so when I join the game, because I created the gamepass, it shows [VIP] for me and now [Owner] as I own the gamepass.
Can I chance the VIP script so it excludes me and it gives everyone but me that chat tag?

-The script for the VIP gamepass:

local MarketplaceService = game:GetService(“MarketplaceService”)
local GamepassID = 66893336 – 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)

-The script for the owner chat tag:

local ServerScriptService = game:GetService(“ServerScriptService”)
local ChatService = require(ServerScriptService:WaitForChild(“ChatServiceRunner”):WaitForChild(“ChatService”))
local Players = game:GetService(“Players”)
local Owner = {‘ptkalx’} --Change Username to your username

ChatService.SpeakerAdded:Connect(function(PlrName)
local Speaker = ChatService:GetSpeaker(PlrName)
for _, v in pairs(Owner) do
if Players[PlrName].Name == v then
Speaker:SetExtraData(‘Tags’, {{TagText = “Owner”, TagColor = Color3.fromRGB(0, 145, 255)}})
Speaker:SetExtraData(‘NameColor’, Color3.fromRGB(255, 238, 0))
Speaker:SetExtraData(‘ChatColor’, Color3.fromRGB(0, 145, 255))
end
end
end)

Thank you in advance!

3 Likes

You can just add a simple if not statement, to check whether the Player instance’s UserId matches yours.

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

    if Player.UserId ~= game.CreatorId then
    -- Code here for inserting chattag. 
    end
end)

Also, please add a ``` at the start of your code to properly format it in the DevForum, instead of using a blockquote!

1 Like

in the vip script, check if the Player Is you if it is then exit the function

if Player.UserId == YourUserId then return end
game.Players.PlayerAdded:Connect(function(Player)
if Player.UserId == YourUserId then return end
end)
1 Like

Can you explain more easy please? I dont know how to script really well…

1 Like

Could you please tell me where in the script I need to paste your lines?

1 Like

just after the PlayerAdded Event like so :

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

game.Players.PlayerAdded:Connect(function(Player) --When player join in game
if Player.UserId == YourUserId then return end
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)
2 Likes

So I just need to remove my script and paste this one right?

2 Likes

And user id is my roblox id or my username or what…?

2 Likes

May not be the best at explaining this, but I’ll try!

if Player.UserId ~= game.CreatorId then

This is basically checking if the current Player instance, when their character just got added, for their UserId, and comparing it with the Creator’s UserId (A.K.A, you!)

~= means ‘not equal to’, so if the script detects that the Player instance’s UserId is the same as the Creator’s, it will skip the Script for the Creator.

2 Likes

yes user id, i suggest using userid instead of usernames cuz if you’re using your username instead, you might change it in the future, however your userid would never change.

2 Likes

This script seems to have many errors as roblox says…

1 Like

Could you too please insert your code in my script?

1 Like

I am not sure where I should put it…

1 Like

shouldn’t cause any errors, did you replace “YourUserId” with your roblox userid?

1 Like


As you can see a lot of errors that roblox finds…

His script doesn’t have any errors.

The comments are just broken & the quotations are broken.

remove “– Change ‘000000’ to your Gamepass ID”
or just make it “-- Change ‘000000’ to your Gamepass ID”

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

game.Players.PlayerAdded:Connect(function(Player) --When player join in game

if Player.UserId ~= game.CreatorId then

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

(Was not able to place spaces due to not being in Studio right now, sorry!)

So where do I need to put them? I am not good at this… :sob:

this should work.
replace YourUserId to your roblox userid

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

game.Players.PlayerAdded:Connect(function(Player) --When player join in game
if Player.UserId == YourUserId then return end
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)