|
I want to add color for vips but idk how, I tried it on the chatdisplayscript but only changes all the chat lines colors I need it to be one individual color for each vip. the color for vip is (0, 1, 0)
ServerScript:
local MAX_MESSAGES = 11
-- a dictionary between players and the list of messages they should see
-- note the use of weak tables (http://wiki.roblox.com/index.php?title=Weak_tables)
-- to save memory, so that message lists are kept only while the player is in game
local messageData = setmetatable({}, {__mode='k'})
-- function to store filtered message for each player and send update
local function storeMessage(sender, message, rank, filteredMessage)
-- loop through all players in the game
for _, player in pairs(game.Players:GetPlayers()) do
-- filter message
local filteredMessage = rank .. sender .. " > " .. game.Chat:FilterStringForPlayerAsync(player, message)
-- get table containing past messages
local playerMessages = messageData[player]
-- add new message to table
table.insert(playerMessages, filteredMessage)
-- check if table is full. If so, remove the oldest message
if #playerMessages > MAX_MESSAGES then
table.remove(playerMessages, 1)
end
-- send update to the player
game.ReplicatedStorage.SendMessages:FireClient(player, playerMessages)
end
end
-- bind function to when player joins the game
game.Players.PlayerAdded:connect(function(player)
-- setup table to hold messages for the player
local playerMessages = {}
messageData[player] = playerMessages
-- bind function to player chat
player.Chatted:connect(function(message, rank)
if player.Name == "xXRevengeCreeperXx" then
rank = "(Owner)"
elseif player.Name == "Austin452w" then
rank = "(Game Admin)"
elseif player.Name == "thegoodpuppy" then
rank = "(Game Admin)"
elseif player.Name == "ElkHunterKiller" then
rank = "(General Of The Army)"
elseif player.Name == "Player" then
rank = "(Testing Is In Progress)"
elseif game:GetService("GamePassService"):PlayerHasPass(player, 273532201) then
rank = "(VIP)"
else
rank = ""
end
storeMessage(player.Name, message, rank)
end)
-- A player's GUI gets reset on respawn so we need to update the gui with the player's
-- messages when they respawn
player.CharacterAdded:connect(function(character)
game.ReplicatedStorage.SendMessages:FireClient(player, playerMessages)
end)
end)
ChatDisplayScript:
local chatFrame = script.Parent.ChatFrame
local Name = game.Players.LocalPlayer
local player = game.Players.LocalPlayer
-- Bind function to update from server
game.ReplicatedStorage.SendMessages.OnClientEvent:connect(function(messages)
-- Clear all of the current messages
chatFrame:ClearAllChildren()
-- Create TextLabel for every message
for i, message in pairs(messages) do
local newLine = Instance.new("TextLabel", chatFrame)
newLine.Text = message
newLine.Size = UDim2.new(1,0,0,18)
newLine.Position = UDim2.new(0,0,0,18*(i-1))
newLine.TextXAlignment = Enum.TextXAlignment.Left
newLine.TextYAlignment = Enum.TextYAlignment.Center
newLine.BackgroundTransparency = 1
newLine.BorderSizePixel = 0
newLine.FontSize = Enum.FontSize.Size18
newLine.Font = Enum.Font.SourceSans
newLine.TextColor3 = Color3.new(1, 1, 1)
newLine.TextStrokeTransparency = 0
end
end) |