local m=announcement.Transparency function createAnnouncement(n)announcement.AnnouncementText.Text=""announcement.AnnouncementText.TextTransparency=0 announcement.Transparency=1 announcement.Visible=true local w=TweenInfo.new(.4,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)local L=ts:Create(announcement,w,{Transparency=m})L:Play()task.wait(.3)for m=1,string.len(n),1 do announcement.AnnouncementText.Text=string.sub(n,1,m)local w=string.sub(n,m,m)task.wait(w=="\n"and.3 or w==" "and.04 or.02)end local t=string.len(n)/16 task.wait(t)local d=ts:Create(announcement,w,{Transparency=1})d:Play()local p=ts:Create(announcement.AnnouncementText,w,{TextTransparency=1})p:Play()p.Completed:Wait()announcement.Visible=false end re.OnClientEvent:Connect(function(m,n)if m=="\065\078\078\079\085\078\067\069"then createAnnouncement(n)end end)

local goalTransparency = announcement.Transparency

function createAnnouncement(message)
	announcement.AnnouncementText.Text = ""
	announcement.AnnouncementText.TextTransparency = 0
	announcement.Transparency = 1
	announcement.Visible = true

	local fadeTweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
	local fadeInTween = ts:Create(announcement, fadeTweenInfo, {Transparency = goalTransparency})
	fadeInTween:Play()
	task.wait(0.3)

	for i = 1, string.len(message) do
		announcement.AnnouncementText.Text = string.sub(message, 1, i)
		local currentChar = string.sub(message, i, i)
		task.wait(currentChar == "\n" and 0.3 or currentChar == " " and 0.04 or 0.02)
	end

	local announcementTime = string.len(message) / 16
	task.wait(announcementTime)

	local fadeOutTween = ts:Create(announcement, fadeTweenInfo, {Transparency = 1})
	fadeOutTween:Play()
	local fadeTextTween = ts:Create(announcement.AnnouncementText, fadeTweenInfo, {TextTransparency = 1})
	fadeTextTween:Play()
	
	fadeTextTween.Completed:Wait()
	announcement.Visible = false
end

re.OnClientEvent:Connect(function(instruction, message)
	if instruction == "ANNOUNCE" then
		createAnnouncement(message)
	end
end)

