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

What did I do wrong? GUI won't load.

Asked by
Aesro 0
10 years ago

I have no clue what I did wrong in this script. I will not load the GUI. Help please?

local admins={"Aesro","Player1"}
local adminSymbol="[Owner] "    -- Symbol that shows someone is a admin.

local teamChat=true     -- Are players allowed to talk in team.
local chatSymbol="%"    -- Used to talk in team.

script.ChatGui:Clone().Parent=game.StarterGui
game:GetService("Players").PlayerAdded:connect(function(Player)
    Player.Chatted:connect(function(msg)

        if msg:sub(1,1)==chatSymbol and teamChat then -- Checking for teamChat.
            for _,p in pairs(game.Players:GetChildren())do
                if p:IsA("Player") and p.TeamColor==Player.TeamColor and p.PlayerGui:findFirstChild("ChatGui") then
                    local label=p.PlayerGui.ChatGui.Message:Clone()
                    label.Parent=p.PlayerGui.ChatGui.Frame
                    label.Visible=false


                    local admin=false -- Checking to see if PLAYER is admin.
                    for i=1,#admins do
                        if Player.Name==admins[i] then admin=true end
                    end
                    if admin then
                        label.NAME.Text=adminSymbol..""..Player.Name..":"
                        label.Text=adminSymbol..""..Player.Name..": "..msg
                        label.NAME.TextColor3=0, 85, 255
                    elseif not admin then
                        label.NAME.Text=Player.Name..":"
                        label.Text=Player.Name..": "..msg
                        label.NAME.TextColor3=255, 255, 255
                    end

                    -- Moves the messages up the frame.
                    for _,m in pairs(p.PlayerGui.ChatGui.Frame:GetChildren())do
                        if m.Name=="Message" then
                            m.Position=m.Position-UDim2.new(0,0,0,15)
                            if m.Position.Y.Offset<(-90) then m:Destroy() end
                        end
                    end

                end
            end

        elseif msg:sub(1,3)~="/e " then
            for _,p in pairs(game.Players:GetChildren())do
                if p:IsA("Player") and p.PlayerGui:findFirstChild("ChatGui") then
                    local label=p.PlayerGui.ChatGui.Message:Clone()
                    label.Parent=p.PlayerGui.ChatGui.Frame
                    label.Visible=false



                    local admin=false -- Checking to see if PLAYER is admin.
                    for i=1,#admins do
                        if Player.Name==admins[i] then admin=true end
                    end
                    if admin then
                        label.NAME.Text=adminSymbol..""..Player.Name..":"
                        label.Text=adminSymbol..""..Player.Name..": "..msg
                        label.NAME.TextColor3=0, 85, 255
                    elseif not admin then
                        label.NAME.Text=Player.Name..":"
                        label.Text=Player.Name..": "..msg
                        label.NAME.TextColor3=255, 255, 255
                    end

                end
            end

        end
    end)
end)

Answer this question