Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make admins chat appear differently [Custom chat GUI]?

Asked by
Prioxis 673 Moderation Voter
10 years ago

here is my custom chat gui script

function UpdateOldLabels(Parent)
    for i,v in pairs(Parent:GetChildren()) do
        if v.Name:sub(1,4):lower() == "line" then
            local LineNumber = v.Name:sub(5)
            if LineNumber == "12" then
                v:Destroy()
            else
                v.Name = "line"..tostring(tonumber(LineNumber) + 1)
                v.Position = v.Position - UDim2.new(0,0,0,15)
            end
        end
    end
end

game:GetService("Players").PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        for _,v in ipairs(game:GetService("Players"):GetChildren()) do
            UpdateOldLabels(v:WaitForChild("PlayerGui").ScreenGui.Frame)
            newchatline = Instance.new("TextLabel",v:WaitForChild("PlayerGui").ScreenGui.Frame)
            newchatline.Text = player.Name.. ": " ..msg
            newchatline.Size = UDim2.new(1,0,0,15)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "SourceSansBold"
            newchatline.TextColor3 = Color3.new(1,1,1)
            newchatline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 0.5
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size14"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
        end
        UpdateOldLabels(game:GetService("StarterGui").ScreenGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ScreenGui.Frame
    end)
end)

but now I know I need a table in order to find the player name and change their chat color when they chat but I don't know how to do that will someone mind contributing the snippet of code I need?

1 answer

Log in to vote
0
Answered by 10 years ago
function inTable(table, value)
    for i,v in next,table do
        if v == value then
            return true;
        end
    end

    return false;
end

Then use it like this:

if inTable(admins, player.Name) then
    -- change the text color of the label
end
Ad

Answer this question