if year==2007 then script.Parent.ClickToChat.TextColor3=Color3.new(0,0,0)script.Parent.ChatBar.BackgroundColor3=Color3.new(1.0,1.0,1.0)end local A={ChatColors={BrickColor.new("\066\114\105\103\104\116 \114\101\100"),BrickColor.new("\066\114\105\103\104\116 \098\108\117\101"),BrickColor.new("\069\097\114\116\104 \103\114\101\101\110");BrickColor.new("\066\114\105\103\104\116 \118\105\111\108\101\116");BrickColor.new("\066\114\105\103\104\116 \111\114\097\110\103\101"),BrickColor.new("\066\114\105\103\104\116 \121\101\108\108\111\119");BrickColor.new("\076\105\103\104\116 \114\101\100\100\105\115\104 \118\105\111\108\101\116"),BrickColor.new("\066\114\105\099\107 \121\101\108\108\111\119")};Gui=nil,Frame=nil,RenderFrame=nil,TapToChatLabel=nil,ClickToChatButton=nil;Templates=nil,EventListener=nil;MessageQueue={},Configuration={FontSize=Enum.FontSize.Size12,NumFontSize=12;HistoryLength=20,Size=UDim2.new(.38,0,.2,0),MessageColor=Color3.new(1,1,1);AdminMessageColor=Color3.new(1,.84313725490196,0);XScale=.025,LifeTime=45;Position=UDim2.new(0,2,.05,0);DefaultTweenSpeed=.15};CachedSpaceStrings_List={},Messages_List={};MessageThread=nil;TempSpaceLabel=nil}function GetNameValue(A)local r=0 for t=1,#A,1 do local B=string.byte(string.sub(A,t,t))local h=(#A-t)+1 if#A%2==1 then h=h-1 end if h%4>=2 then B=-B end r=r+B end return r%8 end function A.ComputeChatColor(r,A)return r.ChatColors[GetNameValue(A)+1].Color end function A.UpdateQueue(t,A,r)for B=#t.MessageQueue,1,-1 do if t.MessageQueue[B]then for h,I in pairs(t.MessageQueue[B])do if I and(type(I)~="\116\097\098\108\101"and type(I)~="\110\117\109\098\101\114")then if I:IsA("\084\101\120\116\076\097\098\101\108")or I:IsA("\084\101\120\116\066\117\116\116\111\110")then if r then I.Position=I.Position-UDim2.new(0,0,r,0)else if A==t.MessageQueue[B]then I.Position=UDim2.new(t.Configuration.XScale,0,I.Position.Y.Scale-A.Message.Size.Y.Scale,0)else I.Position=UDim2.new(t.Configuration.XScale,0,I.Position.Y.Scale-A.Message.Size.Y.Scale,0)end if I.Position.Y.Scale<-0.01 then I.Visible=false I:Destroy()end end end end end end end end function A.ComputeSpaceString(r,A)local t=" "if not r.TempSpaceLabel then r.TempSpaceLabel=r.Templates.SpaceButton r.TempSpaceLabel.Size=UDim2.new(0,A.AbsoluteSize.X,0,A.AbsoluteSize.Y)end r.TempSpaceLabel.Text=t while r.TempSpaceLabel.TextBounds.X<A.TextBounds.X do t=t.." "r.TempSpaceLabel.Text=t end t=t.." "r.CachedSpaceStrings_List[A.Text]=t r.TempSpaceLabel.Text=""return t end function A.UpdateChat(B,r,t)local h={Player=r,Message=t}if coroutine.status(A.MessageThread)=="\100\101\097\100"then table.insert(A.Messages_List,h)A.MessageThread=coroutine.create(function()for r=1,#A.Messages_List,1 do local t=A.Messages_List[r]A:CreateMessage(t.Player,t.Message)end A.Messages_List={}end)coroutine.resume(A.MessageThread)else table.insert(A.Messages_List,h)end end function A.CreateMessage(B,r,t)local h=r~=nil and r.Name or"\071\065\077\069"t=t:gsub("\094\037\115\042\040\046-\041\037\115\042\036","\037\049")B.MessageQueue[#B.MessageQueue]=#B.MessageQueue>B.Configuration.HistoryLength and nil or B.MessageQueue[#B.MessageQueue]local I=B.Templates.pLabel:clone()I.Name=h I.Text=h.."\059"I.Parent=B.RenderFrame I.TextColor3=r.Neutral and A:ComputeChatColor(h)or r.TeamColor.Color local G=B.CachedSpaceStrings_List[h]or A:ComputeSpaceString(I)local R=B.Templates.mLabel:clone()R.Name=h.." - \109\101\115\115\097\103\101"R.TextColor3=A.Configuration.MessageColor R.Text=G..t R.Parent=B.RenderFrame local v=R.TextBounds.Y R.Size=UDim2.new(1,0,v/B.RenderFrame.AbsoluteSize.Y,0)I.Size=R.Size local a=B.RenderFrame.AbsoluteSize.Y local H=R.TextBounds.Y local V={}V.Player=I V.Message=R V.SpawnTime=tick()table.insert(B.MessageQueue,1,V)A:UpdateQueue(V)end function A.CreateChatBar(A)A.ClickToChatButton=A.Gui:WaitForChild("\067\108\105\099\107\084\111\067\104\097\116")A.ChatBar=A.Gui:WaitForChild("\067\104\097\116\066\097\114")local r=game.Players.LocalPlayer:GetMouse()r.KeyDown:connect(function(r)if r:byte()==47 or r=="\047"then A.ClickToChatButton.Visible=false if year>2007 then A.ChatBar.BackgroundColor3=Color3.new(1.0,1.0,1.0)end A.ChatBar:CaptureFocus()end end)A.ClickToChatButton.MouseButton1Click:connect(function()A.ClickToChatButton.Visible=false if year>2007 then A.ChatBar.BackgroundColor3=Color3.new(1.0,1.0,1.0)end A.ChatBar:CaptureFocus()end)end function A.PlayerChat(r,A)local t=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")t.Name="\078\101\119\077\101\115\115\097\103\101"t.Value=A t.Parent=game.Players.LocalPlayer;(game:GetService("\068\101\098\114\105\115")):AddItem(t,2)end function A.CreateGui(r)r.Gui=script.Parent r.Frame=r.Gui:WaitForChild("\067\104\097\116\070\114\097\109\101")r.RenderFrame=r.Frame:WaitForChild("\067\104\097\116\082\101\110\100\101\114\070\114\097\109\101")r.Templates=r.Gui:WaitForChild("\084\101\109\112\108\097\116\101\115")A:CreateChatBar()r.ChatBar.FocusLost:connect(function(t)if year>2007 then r.ChatBar.BackgroundColor3=Color3.new(.25098039215686,.25098039215686,.25098039215686)end if t and r.ChatBar.Text~=""then local t=r.ChatBar.Text if string.sub(r.ChatBar.Text,1,1)=="\037"then t="\040\084\069\065\077\041 "..string.sub(t,2,#t)end A:PlayerChat(t)if r.ClickToChatButton then r.ClickToChatButton.Visible=true end r.ChatBar.Text=""r.ClickToChatButton.Visible=true end end)end function A.TrackPlayerChats(r)local function t(r)r.ChildAdded:connect(function(t)if t:IsA("\083\116\114\105\110\103\086\097\108\117\101")and t.Name=="\078\101\119\077\101\115\115\097\103\101"then if game.Players.LocalPlayer.Neutral or r.TeamColor==game.Players.LocalPlayer.TeamColor then A:UpdateChat(r,t.Value)end end end)end for A,r in pairs(game.Players:GetPlayers())do t(r)end game.Players.PlayerAdded:connect(t)end function A.CullThread(A)Spawn(function()while true do if#A.MessageQueue>0 then for r,t in pairs(A.MessageQueue)do if t.SpawnTime and(t.Player and(t.Message and tick()-t.SpawnTime>A.Configuration.LifeTime))then t.Player.Visible=false t.Message.Visible=false end end end wait(5)end end)end function A.Initialize(r)A:CreateGui()A:TrackPlayerChats()r.MessageThread=coroutine.create(function() end)coroutine.resume(r.MessageThread)A:CullThread()end A:Initialize()
--Code

if year == 2007 then
	script.Parent.ClickToChat.TextColor3 = Color3.new(0, 0, 0)
	script.Parent.ChatBar.BackgroundColor3 = Color3.new(255 / 255, 255 / 255, 255 / 255)
end

local Chat = {
	ChatColors = {
		BrickColor.new("Bright red"),
		BrickColor.new("Bright blue"),
		BrickColor.new("Earth green"),
		BrickColor.new("Bright violet"),
		BrickColor.new("Bright orange"),
		BrickColor.new("Bright yellow"),
		BrickColor.new("Light reddish violet"),
		BrickColor.new("Brick yellow"),
	},

	Gui = nil,
	Frame = nil,
	RenderFrame = nil,
	TapToChatLabel = nil,
	ClickToChatButton = nil,
	Templates = nil,
	EventListener = nil,
	MessageQueue = {},

	Configuration = {
		FontSize = Enum.FontSize.Size12,
		NumFontSize = 12,
		HistoryLength = 20,
		Size = UDim2.new(0.38, 0, 0.20, 0),
		MessageColor = Color3.new(1, 1, 1),
		AdminMessageColor = Color3.new(1, 215 / 255, 0),
		XScale = 0.025,
		LifeTime = 45,
		Position = UDim2.new(0, 2, 0.05, 0),
		DefaultTweenSpeed = 0.15,
	},

	CachedSpaceStrings_List = {},
	Messages_List = {},
	MessageThread = nil,
	TempSpaceLabel = nil,
}

function GetNameValue(pName)
	local value = 0
	for index = 1, #pName do
		local cValue = string.byte(string.sub(pName, index, index))
		local reverseIndex = #pName - index + 1
		if #pName % 2 == 1 then
			reverseIndex = reverseIndex - 1
		end
		if reverseIndex % 4 >= 2 then
			cValue = -cValue
		end
		value = value + cValue
	end
	return value % 8
end

function Chat:ComputeChatColor(pName)
	return self.ChatColors[GetNameValue(pName) + 1].Color
end

function Chat:UpdateQueue(field, diff)
	for i = #self.MessageQueue, 1, -1 do
		if self.MessageQueue[i] then
			for _, label in pairs(self.MessageQueue[i]) do
				if label and type(label) ~= "table" and type(label) ~= "number" then
					if label:IsA("TextLabel") or label:IsA("TextButton") then
						if diff then
							label.Position = label.Position - UDim2.new(0, 0, diff, 0)
						else
							if field == self.MessageQueue[i] then
								label.Position = UDim2.new(
									self.Configuration.XScale,
									0,
									label.Position.Y.Scale - field["Message"].Size.Y.Scale,
									0
								)
							else
								label.Position = UDim2.new(
									self.Configuration.XScale,
									0,
									label.Position.Y.Scale - field["Message"].Size.Y.Scale,
									0
								)
							end
							if label.Position.Y.Scale < -0.01 then
								label.Visible = false
								label:Destroy()
							end
						end
					end
				end
			end
		end
	end
end

function Chat:ComputeSpaceString(pLabel)
	local nString = " "
	if not self.TempSpaceLabel then
		self.TempSpaceLabel = self.Templates.SpaceButton
		self.TempSpaceLabel.Size = UDim2.new(0, pLabel.AbsoluteSize.X, 0, pLabel.AbsoluteSize.Y)
	end
	self.TempSpaceLabel.Text = nString
	while self.TempSpaceLabel.TextBounds.X < pLabel.TextBounds.X do
		nString = nString .. " "
		self.TempSpaceLabel.Text = nString
	end
	nString = nString .. " "
	self.CachedSpaceStrings_List[pLabel.Text] = nString
	self.TempSpaceLabel.Text = ""
	return nString
end

function Chat:UpdateChat(cPlayer, message)
	local messageField = { ["Player"] = cPlayer, ["Message"] = message }
	if coroutine.status(Chat.MessageThread) == "dead" then
		table.insert(Chat.Messages_List, messageField)
		Chat.MessageThread = coroutine.create(function()
			for i = 1, #Chat.Messages_List do
				local field = Chat.Messages_List[i]
				Chat:CreateMessage(field["Player"], field["Message"])
			end
			Chat.Messages_List = {}
		end)
		coroutine.resume(Chat.MessageThread)
	else
		table.insert(Chat.Messages_List, messageField)
	end
end

function Chat:CreateMessage(cPlayer, message)
	local pName = cPlayer ~= nil and cPlayer.Name or "GAME"
	message = message:gsub("^%s*(.-)%s*$", "%1")
	self.MessageQueue[#self.MessageQueue] = (#self.MessageQueue > self.Configuration.HistoryLength) and nil
		or self.MessageQueue[#self.MessageQueue]
	local pLabel = self.Templates.pLabel:clone()
	pLabel.Name = pName
	pLabel.Text = pName .. ";"
	pLabel.Parent = self.RenderFrame
	pLabel.TextColor3 = cPlayer.Neutral and Chat:ComputeChatColor(pName) or cPlayer.TeamColor.Color
	local nString = self.CachedSpaceStrings_List[pName] or Chat:ComputeSpaceString(pLabel)
	local mLabel = self.Templates.mLabel:clone()
	mLabel.Name = pName .. " - message"
	mLabel.TextColor3 = Chat.Configuration.MessageColor
	mLabel.Text = nString .. message
	mLabel.Parent = self.RenderFrame
	local heightField = mLabel.TextBounds.Y
	mLabel.Size = UDim2.new(1, 0, heightField / self.RenderFrame.AbsoluteSize.Y, 0)
	pLabel.Size = mLabel.Size
	local yPixels = self.RenderFrame.AbsoluteSize.Y
	local yFieldSize = mLabel.TextBounds.Y
	local queueField = {}
	queueField["Player"] = pLabel
	queueField["Message"] = mLabel
	queueField["SpawnTime"] = tick()
	table.insert(self.MessageQueue, 1, queueField)
	Chat:UpdateQueue(queueField)
end

function Chat:CreateChatBar()
	self.ClickToChatButton = self.Gui:WaitForChild("ClickToChat")
	self.ChatBar = self.Gui:WaitForChild("ChatBar")
	local mouse = game.Players.LocalPlayer:GetMouse()
	mouse.KeyDown:connect(function(key)
		if key:byte() == 47 or key == "/" then
			self.ClickToChatButton.Visible = false
			if year > 2007 then
				self.ChatBar.BackgroundColor3 = Color3.new(255 / 255, 255 / 255, 255 / 255)
			end
			self.ChatBar:CaptureFocus()
		end
	end)
	self.ClickToChatButton.MouseButton1Click:connect(function()
		self.ClickToChatButton.Visible = false
		if year > 2007 then
			self.ChatBar.BackgroundColor3 = Color3.new(255 / 255, 255 / 255, 255 / 255)
		end
		self.ChatBar:CaptureFocus()
	end)
end

function Chat:PlayerChat(message)
	local m = Instance.new("StringValue")
	m.Name = "NewMessage"
	m.Value = message
	m.Parent = game.Players.LocalPlayer
	game:GetService("Debris"):AddItem(m, 2)
end

function Chat:CreateGui()
	self.Gui = script.Parent
	self.Frame = self.Gui:WaitForChild("ChatFrame")
	self.RenderFrame = self.Frame:WaitForChild("ChatRenderFrame")
	self.Templates = self.Gui:WaitForChild("Templates")
	Chat:CreateChatBar()
	self.ChatBar.FocusLost:connect(function(enterPressed)
		if year > 2007 then
			self.ChatBar.BackgroundColor3 = Color3.new(64 / 255, 64 / 255, 64 / 255)
		end
		if enterPressed and self.ChatBar.Text ~= "" then
			local cText = self.ChatBar.Text
			if string.sub(self.ChatBar.Text, 1, 1) == "%" then
				cText = "(TEAM) " .. string.sub(cText, 2, #cText)
			end
			Chat:PlayerChat(cText)
			if self.ClickToChatButton then
				self.ClickToChatButton.Visible = true
			end
			self.ChatBar.Text = ""
			self.ClickToChatButton.Visible = true
		end
	end)
end

function Chat:TrackPlayerChats()
	local function chatRegister(p)
		p.ChildAdded:connect(function(obj)
			if obj:IsA("StringValue") and obj.Name == "NewMessage" then
				if game.Players.LocalPlayer.Neutral or p.TeamColor == game.Players.LocalPlayer.TeamColor then
					Chat:UpdateChat(p, obj.Value)
				end
			end
		end)
	end
	for _, v in pairs(game.Players:GetPlayers()) do
		chatRegister(v)
	end
	game.Players.PlayerAdded:connect(chatRegister)
end

function Chat:CullThread()
	Spawn(function()
		while true do
			if #self.MessageQueue > 0 then
				for _, field in pairs(self.MessageQueue) do
					if
						field["SpawnTime"]
						and field["Player"]
						and field["Message"]
						and tick() - field["SpawnTime"] > self.Configuration.LifeTime
					then
						field["Player"].Visible = false
						field["Message"].Visible = false
					end
				end
			end
			wait(5)
		end
	end)
end

function Chat:Initialize()
	Chat:CreateGui()
	Chat:TrackPlayerChats()
	self.MessageThread = coroutine.create(function() end)
	coroutine.resume(self.MessageThread)
	Chat:CullThread()
end

Chat:Initialize()
