I need a filter on my chat before my game dies if anybody would help that is nice.. Here is the script:

--_*~ MAIN LOCALS ~*_--
local Events 		= workspace:WaitForChild('Events')
local ChatFired 	= Events:WaitForChild('ChatFired')
local yar 			= script
local Chat 			= script.Parent:WaitForChild('ChatFrame')
local Temp 			= yar:WaitForChild('Temp')
local Memb 			= yar:WaitForChild('Memb')
local test 			= yar:WaitForChild('Testing')
local Player		= game.Players.LocalPlayer
local Membership 	= game.ReplicatedStorage:WaitForChild(Player.Name..'Membership').Value
local Level 	= game.ReplicatedStorage:WaitForChild(Player.Name..'Level').Value
local fakename 		= game.ReplicatedStorage:WaitForChild(Player.Name..'FakeName').Value
local muted 		= Player:WaitForChild('Muted').Value
local Character		= Player.Character or Player.CharacterAdded:wait()
local Mouse			= Player:GetMouse()
local rs			= game:GetService("RunService").RenderStepped
local canUpdate		= true
local par = false
------------------------

function split(s)
	local t = {""}
	for i = 1, #s do --a few days ago I learned you could do #string instead of string.len(string)
		if string.sub(s, i, i) == " " then
			t[#t + 1] = ""
		else
			t[#t] = t[#t]..string.sub(s, i, i)
		end
	end
	return t
end

--_~* MAIN FUNCTIONS / CLIENT FUNCTIONS *~_--

local function rankColor(rank)
	if rank == "Player" then
		return Color3.new(1,1,1)
	elseif rank == "" then
		return Color3.new(0,1,0)
	elseif rank == "" then
		return Color3.new(92/255, 138/255, 138/255)
	elseif rank == "Ambassador" then
		return Color3.new(1,1,0)
	elseif rank == "Owner" then
		return Color3.new(1,0,0)
	end
end

local function levelColor(rank)
	if rank == 1000 then
		return Color3.new(0.2,0.2,0.8)
	elseif rank == 999 then
		return Color3.new(1,1,0)
	elseif rank ~= 999 or rank ~= 1000 then
		return Color3.new(0.7,0,0.7)
	elseif rank < 1000 then
		return Color3.new(1,0,0)
	end
end

local function playerNameColor(plr)
	if plr.Name == "Player" then
		return BrickColor.Random().Color
	elseif plr.Name == "" then
		return BrickColor.new('Really red').Color
	elseif plr.Name == "" then
		return BrickColor.new('Really red').Color
	elseif plr.Name == "safouan501" then
		return BrickColor.new('Really red').Color
	else
		return BrickColor.new("Lime green").Color
	end
end

local boxClone = Player:FindFirstChild("ChatFrame")
if boxClone then
	Chat:Destroy()
	boxClone.Parent = script.Parent
	Chat = boxClone
end

local function SendMessage(p,m,r,lvl,mC, kek)
	local chats = Chat:GetChildren()
	local membr = p and game.ReplicatedStorage[p.Name.."Membership"].Value
	local members = p and game.ReplicatedStorage[p.Name.."Level"].Value
	---------
	local prm = test:Clone()
	prm.Parent = Chat
	local mem = Memb:Clone()
	mem.Parent = prm
	mem.Text = "["..membr.."]"
	mem.TextColor3 = rankColor(membr)
	mem.Name = "Rank1"
	local lvle = Temp:Clone()
	lvle.Parent = prm
	lvle.Text = " ["..members.."] "
	lvle.Name = "Rank1"
	lvle.TextColor3 = levelColor(lvl)
	local plr = Temp:Clone()
	plr.Parent = prm
	plr.Text = p.Name..": "
	plr.Name = "Rank1"
	plr.TextColor3 = playerNameColor(p)
	local msg = Temp:Clone()
	msg.Parent = prm
--	if p.Name == "Player" then
--	local rain = script.Rainbower:Clone()
--	rain.Parent = plr
--	rain.Disabled = false
--	local kekz = script.RainbowFrame:Clone()
--	kekz.Position = UDim2.new(0,plr.TextBounds.X-lvle.TextBounds.X-20,0.2,0)
--	kekz.Size = UDim2.new(0,plr.TextBounds.X+lvle.TextBounds.X,0,20)
--	kekz.BackgroundTransparency = 1
--	kekz.Parent = plr
--	end
	if kek and membr == "Magic Council" or membr == "Owner" then
	msg.Text = string.gsub(m,'&i','')
	local rain = script.Rainbower:Clone()
	rain.Parent = msg
	rain.Disabled = false
	local kekz = script.RainbowFrame:Clone()
	kekz.Position = UDim2.new(0,msg.TextBounds.X-11,0.2,0)
	kekz.Size = UDim2.new(0,msg.TextBounds.X-20,0,20)
	kekz.BackgroundTransparency = 1
	kekz.Parent = msg
	elseif membr == "Owner" then
	local rain = script.Rainbower:Clone()
	rain.Parent = msg
	msg.Text = m
	rain.Disabled = false	
	elseif p.Name == ""then
	local rain = script.FearChat:Clone()
	rain.Parent = plr
	msg.Text = m
	rain.Disabled = false		
	else msg.Text = m
	end
	if p.Name == "" or p.Name == "" or p.Name == "" or p.Name == "" or p.Name == "" then
	local rain = script.FearChat:Clone()
	rain.Parent = mem
	msg.Text = m
	rain.Disabled = false		
	else
	msg.Text = m
	end
	msg.Name = "Rank1"
	msg.TextColor3 = mC
	rs:wait()
	lvle.Position = UDim2.new(0,mem.TextBounds.X,0.2,0)
	plr.Position = UDim2.new(0,mem.TextBounds.X+lvle.TextBounds.X,0.2,0)
	msg.Position = UDim2.new(0,mem.TextBounds.X+lvle.TextBounds.X+plr.TextBounds.X,0.2,0)
			for x = 1, #chats do
				chats[x].Position = chats[x].Position + UDim2.new(0, 0, 0, -20)
				if chats[x].Position.Y.Offset <= -120 then
				chats[x]:remove()
				end
			end
end

ChatFired.OnClientEvent:connect(function(plr,msg,rek,lvlel,mC, kek)
	if plr.Name ~= Player.Name then
		--UpdateRanks(Chat,0)
		SendMessage(plr,msg,rek,lvlel,mC, kek)
	end
end)

--function UpdateRanks(Parent,LS)
--    for i,v in pairs(Parent:GetChildren()) do
--        if v.Name:sub(1,4):lower() == "rank" then
--            local LineNumber = v.Name:sub(5)
--            if LineNumber == "8" then
--                v:Destroy()
--            else
--                v.Name = "rank"..tostring(tonumber(LineNumber) + 1)
--                v.Position = v.Position + UDim2.new(0,0,0,-25-LS)
--            end
--        end
--	end 
--end
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:connect(function()
	canUpdate = false
	local boxClone = Chat:Clone(); Chat.Parent = Player
end)

Player.Chatted:connect(function(msg)
	--UpdateRanks(Chat,0)
for i,c in pairs(split(msg)) do
	if string.lower(c) == "&i" then
		msg = string.gsub(msg,"&i","")
		par = true
	end
end
	SendMessage(Player,msg,Membership,Level,Color3.new(1,1,1), par)
	rs:wait()
	ChatFired:FireServer(msg,Membership,Level,Color3.new(1,1,1), par)
	par = false
end)
---------------------------------------------

2 comments

0

This page shows you how to filter a string for chat. http://wiki.roblox.com/index.php?title=Custom_chat_GUI

0

I'm Sorry but my game will die And i tried that either but i dont know where to add it im still learning how to script