local z=announcement.Transparency function createAnnouncement(c)announcement.AnnouncementText.Text=""announcement.AnnouncementText.TextTransparency=0 announcement.Transparency=1 announcement.Visible=true local I=TweenInfo.new(.4,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)local u=ts:Create(announcement,I,{Transparency=z})u:Play()task.wait(.3)for z=1,string.len(c),1 do announcement.AnnouncementText.Text=string.sub(c,1,z)local I=string.sub(c,z,z)task.wait(I=="\n"and.3 or I==" "and.04 or.02)end local F=string.len(c)/16 task.wait(F)local P=ts:Create(announcement,I,{Transparency=1})P:Play()local S=ts:Create(announcement.AnnouncementText,I,{TextTransparency=1})S:Play()S.Completed:Wait()announcement.Visible=false end re.OnClientEvent:Connect(function(z,c)if z=="\065\078\078\079\085\078\067\069"then createAnnouncement(c)end end)
--Receive announcements
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)
