I want to make a script similar to a VIP script. I want it to say [TITLEHERE} (playernamehere)
The current script I have is
local ServerScriptService = game:GetService("ServerScriptService")
local MPS = game:GetService("MarketplaceService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local players = game:GetService("Players")
local WondersPlatinumID = 6581175
ChatService.SpeakerAdded:Connect(function(PlayerID)
local Speaker = ChatService:GetSpeaker(PlayerID)
if MPS:UserOwnsGamePassAsync(players[PlayerID].UserId,WondersPlatinumID)then
Speaker:SetExtraData('Tags', {{TagText = "💎WONDERS PLATINUM💎", TagColor = Color3.fromRGB(137, 207, 240)}})
end
end)
A post was already made on this, you can find it here with the solution Chat coding: Working with tags and name colours? . Please look through the forum for a similar topic before posting in the scripting support category for help.
Maybe you meant to use GetPlayer instead, the one that returns the actual player object? The lack of information in the thread is crippling to determine a source of error, but I would assume this is the cause given what I’ve read from your code.
GetPlayer will automatically return the player object, so you only need for a non-nil player and their UserId. As for SpeakerAdded, it fires with the speaker rather than the player or their UserId. If you need an API reference, check out the Lua Chat System documentation.
Make sure to also create a catcher function to account for existing speakers.
Below, I’ve fixed up your code to properly use the ChatService API. Make sure to learn from it (check what I did differently) and use the previously mentioned documentation as a reference when working with the Chat system.
local ServerScriptService = game:GetService("ServerScriptService")
local MarketplaceService = game:GetService("MarketplaceService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner").ChatService)
local PLATINUM_ID = 6581175
local function speakerAdded(speaker)
local player = speaker:GetPlayer()
if player then
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PLATINUM_ID) then
speaker:SetExtraData("Tags", {{TagText = "💎WONDERS PLATINUM💎", TagColor = Color3.fromRGB(137, 207, 240)}})
end
end
end
ChatService.SpeakerAdded:Connect(speakerAdded)
for _, speaker in ipairs(ChatService:GetSpeakerList()) do
speakerAdded(speaker)
end