Hello, I want to make a script that if the player has the V.I.P gamepass, the player gets a V.I.P chat tag. I would like some examples, or tutorials. Thank you.
Hi Ojnim, you actually need two pieces of codes for this to work:
You need the piece of code that adds the actual tag to the chat:
This can be pretty daunting, so I made a simplified version for you that you have to make changes to in order to make it work, a little challenge:
local ChatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local vipTag = {TagText = "VIP", TagColor = Color3.fromRGB(255, 0, 0)}
local function isUserVIP(UserId)
-- this function should either return true or return false
end
ChatService.SpeakerAdded:Connect(function(SpeakerName)
local UserId = Players:FindFirstChild(SpeakerName).UserId
local Speaker = ChatService:GetSpeaker(SpeakerName)
-- logic for checking if user is 'VIP' you should put here
Speaker:SetExtraData("Tags", {vipTag})
end)
Then you need a second part to make the script work, you need to check if the user actually has your game pass. You can use UserOwnsGamePassAsync for this.
Thank you for the reply. Can I use your script in my game?
Of course, feel free to. Have fun developing your experience!
I have a question, for the first line, is there a way to not use “require”? Is it possible to use game:GetService()?
Yes, I believe you can also put such code as a module script inside of the ChatModules folder.
For code examples, I highly recommend checking out In-Experience Text Chat | Roblox Creator Documentation, as mentioned earlier.
Do I need to put the script that you provided in ServerScriptService, or Chat?