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

Chat Script Won't Work?

Asked by 9 years ago

It is a script in ServerScriptService

local Owner = {["bosswalrus"] = true}
local Mod = {["apolloboss"] = true, ["1Juice1"] = true, ["whitewolf731"] = true, ["damienrocks1"] = true}

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,30)
            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)
            if Owner[player.Name] then
                newchatline.Text = "[Owner]".. player.Name.. ": " ..msg
            end
            if Mod[player.Name] then
                newchatline.Text = "[Moderator]".. player.Name.. ": " ..msg
            end
            if not Owner[player.Name] or not Mod[player.Name] then
                newchatline.Text = player.Name.. ": " ..msg
            end
            newchatline.Size = UDim2.new(1.5,0,0,45)
            newchatline.Position = UDim2.new(0,0,0.5,-20)
            newchatline.Font = "Arial"
            newchatline.TextColor3 = Color3.new(255,255,255)
            newchatline.TextStrokeTransparency = 1
            newchatline.BackgroundTransparency = 1
            newchatline.BorderSizePixel = 0
            newchatline.FontSize = "Size24"
            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)

For some reason the Owner and Mod ranks won't pop up beside name.

0
make sure you account for capitalization. Also, it might be better to use userids as players can change their name. GoldenPhysics 474 — 9y
0
Any errors? GoldenPhysics 474 — 9y

Answer this question