local Players = game:GetService("Players")
local ServerScriptService = game:GetService('ServerScriptService')
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local function onPlayerChatted(PlayerName)
local value = Players.LocalPlayer:WaitForChild("VIP")
if value.Value == true then
local Speaker = ChatService:GetSpeaker(PlayerName)
Speaker:SetExtraData('Tags', {{TagText = 'VIP', TagColor = Color3.fromRGB(255, 255, 0)}})
Speaker:SetExtraData('ChatColor', Color3.fromRGB(255, 247, 0))
end
end
ChatService.SpeakerAdded:Connect(onPlayerChatted)
Seems like you’re using LocalPlayer in a server script. You can’t do this, accessing the LocalPlayer can only be done on the client.
You are able to retrieve the speaker from the SpeakerAdded event instead.
local Players = game:GetService("Players")
local ServerScriptService = game:GetService('ServerScriptService')
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local function onPlayerChatted(PlayerName)
local value = game.Players:FindFirstChild(PlayerName):WaitForChild("VIP")
if value.Value == true then
local Speaker = ChatService:GetSpeaker(PlayerName)
Speaker:SetExtraData('Tags', {{TagText = 'VIP', TagColor = Color3.fromRGB(255, 255, 0)}})
Speaker:SetExtraData('ChatColor', Color3.fromRGB(255, 247, 0))
end
end
ChatService.SpeakerAdded:Connect(function(speakerName)
onPlayerChatted(speakerName)
end)
Hey, I played around with your script and came up with this. It’s working just fine, let me know if it’s useful
local Players = game:GetService("Players")
local ServerScriptService = game:GetService('ServerScriptService')
local MarketplaceService = game:GetService('MarketplaceService')
local passId = 000 -- Gamepass ID
Players.PlayerAdded:Connect(function(Player)
local Bool = Instance.new('BoolValue')
Bool.Parent = Player
Bool.Name = 'VIP'
if MarketplaceService:UserOwnsGamePassAsync(Player.UserId,passId) then
Bool.Value = true
end
end)
local ChatService = require(ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local function onPlayerChatted(PlayerName)
local value = game.Players:FindFirstChild(PlayerName):WaitForChild("VIP")
if value.Value == true then
local Speaker = ChatService:GetSpeaker(PlayerName)
Speaker:SetExtraData('Tags', {{TagText = 'VIP', TagColor = Color3.fromRGB(255, 255, 0)}})
Speaker:SetExtraData('ChatColor', Color3.fromRGB(255, 247, 0))
end
end
ChatService.SpeakerAdded:Connect(function(speakerName)
onPlayerChatted(speakerName)
end)