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

I've tried filtering this chat but just can't do it? [closed]

Asked by 6 years ago

I've tried the roblox wiki and everything but still can't figure out how to filter this chat can someone help?

game.ReplicatedStorage:WaitForChild("Events")
game.ReplicatedStorage.Events:WaitForChild("AddChat")
game.ReplicatedStorage.Events:WaitForChild("FillChats")

game.StarterGui:SetCoreGuiEnabled("Chat",false)

local Player = game.Players.LocalPlayer

local Tags = {
    TheLuaDeveloper = "Dev",
}

local UIS = game:GetService("UserInputService")

local IntervalChat = 0
local Typing = false
local WaitChatting = true

function GetTags(plr)
    if Tags[plr.Name] then
        return " [" .. Tags[plr.Name] .. "] "
    else
        return " "
    end
end

function GetNum(lin)
    if lin < 45 then
        return 20
    elseif lin < 90 then
        return 40
    elseif lin < 135 then
        return 60
    end
end

function MakeChat(plr,cc,speech,tag,ccc)
    local frame = Instance.new("Frame",script.Parent.Back.Chats)
    frame.Size = UDim2.new(1,0,0,20)
    frame.BackgroundTransparency = 1
    local pn = Instance.new("TextLabel",frame)
    pn.Text = tag .. "[" .. plr.Name .. "]: "
    pn.BackgroundTransparency = 1
    pn.TextColor3 = cc
    pn.Name = "namtag"
    pn.Font = "SourceSansBold"
    pn.FontSize = "Size18"
    pn.TextStrokeTransparency = .75
    pn.TextXAlignment = "Left"
    pn.Size = UDim2.new(0,2,0,20)
    repeat
        pn.Size = pn.Size + UDim2.new(0,1,0,0)
    until pn.TextFits == true
    local sn = Instance.new("TextLabel",frame)
    sn.TextXAlignment = "Left"
    sn.Font = "SourceSansBold"
    sn.FontSize = "Size18"
    sn.Name = "speech"
    sn.TextColor3 = ccc
    sn.Text = speech
    sn.BackgroundTransparency = 1
    sn.TextStrokeTransparency = .75
    sn.TextWrapped = true
    sn.Size = UDim2.new(0,5,0,20)
    repeat
        sn.Size = sn.Size + UDim2.new(0,1,0,0)
    until sn.TextFits == true or sn.Size.X.Offset > 400 - pn.Size.X.Offset
    if sn.TextFits == true then
        sn.Position = pn.Position + UDim2.new(0,pn.Size.X.Offset,0,0)
        frame.Position = UDim2.new(0,0,1,-sn.Size.Y.Offset)
    else
        sn.TextYAlignment = "Top"
        sn.Size = UDim2.new(0,400 - pn.Size.X.Offset,0,20)
        sn.Position = pn.Position + UDim2.new(0,2,0,20)
        if sn.TextFits == false then
            if string.len(speech) < 45 then
                sn.Size = UDim2.new(0,400 - pn.Size.X.Offset,0,20)
            elseif string.len(speech) < 90 then
                sn.Size = UDim2.new(0,400 - pn.Size.X.Offset,0,40)
            else
                sn.Size = UDim2.new(0,400 - pn.Size.X.Offset,0,60)
            end
        end
        frame.Size = UDim2.new(1,0,0,sn.Size.Y.Offset + 20)
        frame.Position = UDim2.new(0,0,1,-sn.Size.Y.Offset - 20)
    end
    frame.Parent = nil
    return frame
end


UIS.InputBegan:connect(function(key)
    if key.KeyCode == Enum.KeyCode.Slash and not Typing then
        script.Parent.Back.Type:CaptureFocus()
    end
end)

script.Parent.Back.Type.Focused:connect(function()
    Typing = true
    script.Parent.Back.Type.BackgroundTransparency = 0
    script.Parent.Back.Type.TextStrokeTransparency = 1
    script.Parent.Back.Type.TextColor3 = Color3.new(0,0,0)
    while Typing do
        wait(.1)
        local num = GetNum(string.len(script.Parent.Back.Type.Text))
        if num == 20 then
            script.Parent.Back.Type:TweenSizeAndPosition(UDim2.new(0,400,0,30),UDim2.new(0,5,1,-30),"Out","Quad",.05,true)
        elseif num == 40 then
            script.Parent.Back.Type:TweenSizeAndPosition(UDim2.new(0,400,0,50),UDim2.new(0,5,1,-30),"Out","Quad",.05,true)
        else
            script.Parent.Back.Type:TweenSizeAndPosition(UDim2.new(0,400,0,70),UDim2.new(0,5,1,-30),"Out","Quad",.05,true)
        end
    end
end)                                 

script.Parent.Back.Type.FocusLost:connect(function(Entered)
    Typing = false
    script.Parent.Back.Type.BackgroundTransparency = 1
    script.Parent.Back.Type.TextStrokeTransparency = .5
    script.Parent.Back.Type.TextColor3 = Color3.new(255/255,255/255,255/255)
    if Entered and script.Parent.Back.Type.Text ~= "" then
        game.ReplicatedStorage.Events.AddChat:FireServer(Color3.new(255,255,255),GetTags(Player),script.Parent.Back.Type.Text)
        script.Parent.Back.Type.Text = "Click here or type '/' to chat"
    end
end)

game.ReplicatedStorage.Events.RepChat.OnClientEvent:connect(function(args,p)
    if not WaitChatting then
        local chat = MakeChat(p,p.TeamColor.Color,args[3],args[2],args[1])
        for i,v in pairs(script.Parent.Back.Chats:GetChildren()) do
            v:TweenPosition(UDim2.new(0,0,1,v.Position.Y.Offset - chat.Size.Y.Offset),"Out","Quad",.1,true)
            if v.Position.Y.Offset < -v.Size.Y.Offset -200 then
                v:Destroy()
            end
        end
        chat.Parent = script.Parent.Back.Chats
    end
end)

game.ReplicatedStorage.Events.FillChats.OnClientEvent:connect(function(chats)
    print("Filling")
    for i = #chats,1,-1 do
        if chats[i] then
            local chat = MakeChat(chats[i][2],chats[i][2].TeamColor.Color,chats[i][1][3],chats[i][1][2],chats[i][1][1])
            for i,v in pairs(script.Parent.Back.Chats:GetChildren()) do
                v:TweenPosition(UDim2.new(0,0,1,v.Position.Y.Offset - chat.Size.Y.Offset),"Out","Quad",1/30,true)
                if v.Position.Y.Offset < -v.Size.Y.Offset -200 then
                    v:Destroy()
                end
            end
            chat.Parent = script.Parent.Back.Chats
        else
            WaitChatting = false
        end
        wait()
    end
    WaitChatting = false
end)

Closed as Non-Descriptive by cabbler, User#20388, Troidit, Le_Teapots, DeveloperSolo, and RubenKan

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?