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

How to check a players name? (Working with Custom Chat Gui)

Asked by 10 years ago
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,20)
            newchatline.Position = UDim2.new(0,0,1,-15)
            newchatline.Font = "ArialBold"
            newchatline.TextStrokeTransparency = 0
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size18"
            newchatline.TextXAlignment = "Left"
            newchatline.TextYAlignment = "Top"
            newchatline.ClipsDescendants = true
            newchatline.Name = "line1"
            if player.Name == "NinjoOnline" then
                newchatline.TextColor3 = Color3.new(85, 255, 255)
            elseif player.Name == "rarchet" then
                newchatline.TextColor3 = Color3.new(255, 85, 0)
            elseif player.Name == "daaabosss" then
                newchatline.TextColor3 = Color3.new(255, 85, 0)
            else
                newchatline.TextColor3 = Color3.new(1,1,1)
            end
        end
        UpdateOldLabels(game:GetService("StarterGui").ScreenGui.Frame)
        newchatline:Clone().Parent = game:GetService("StarterGui").ScreenGui.Frame
    end)
end)

Ok so I need it check if the players name is NinjoOnline (line 32) then make the text color cyan, but it keeps it white? Anyone have ideas on what I am doing wrong. Script is in ServerSrciptStorage

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Despite what the Properties tab will show you, the Color3.new constructor takes numbers 0 to 1, not 0 to 255.

Divide each of the parameters by 255:

... = Color3.new(85/255, 1, 1)

(This goes for all of them)

0
Oh wow, I should of know that :p thanks :) NinjoOnline 1146 — 10y
0
so 255 is just 1 (white) and 0 stays as 0 (black) NinjoOnline 1146 — 10y
0
Correct -- it's just scaled up (multiplied) by 255.0 in the properties window BlueTaslem 18071 — 10y
0
Ok thanks, it works :) NinjoOnline 1146 — 10y
Ad

Answer this question