Animation Text Label Billboard GUI

I’m writing billboard gui overhead text with typewriting effect.
It works if I don’t base on team
If I only use

local player = game:GetService("Players")
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnimateUI = require(ReplicatedStorage:WaitForChild("AnimateUI"))
local label = script.Parent


AnimateUI.loadTranslator()

while true do
		local message1 = [[Military Police]]
		AnimateUI.typeWrite(label, message1, 0.05)

		wait(3)

		local message2 = [[Special Reaction Team]]
		AnimateUI.typeWrite(label, message2, 0.05)
		wait(3)
end

It works but without based on team

But if i make like this

local player = game:GetService("Players")
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnimateUI = require(ReplicatedStorage:WaitForChild("AnimateUI"))
local label = script.Parent


AnimateUI.loadTranslator()

while true do
if player.Team == Teams[“Military Police”] then

local message1 = [[Military Police]]
		AnimateUI.typeWrite(label, message1, 0.05)
		wait(3)

		local message2 = [[Special Reaction Team]]
		AnimateUI.typeWrite(label, message2, 0.05)
		wait(3)
end

or

if player.Team == Teams[“Military Police”] then
while true do
local message1 = [[Military Police]]
		AnimateUI.typeWrite(label, message1, 0.05)

		wait(3)

		local message2 = [[Special Reaction Team]]
		AnimateUI.typeWrite(label, message2, 0.05)
		wait(3)
end
end

It doesn’t work the textlabel doesn’t show anything

This is my full script that works (without based on team), but I want to make it based on team that works
AnimateUI Module Script

local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")

local SOURCE_LOCALE = "en"
local translator = nil

local AnimateUI = {}

function AnimateUI.loadTranslator()
	pcall(function()
		translator = LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
	end)
	if not translator then
		pcall(function()
			translator = LocalizationService:GetTranslatorForLocaleAsync(SOURCE_LOCALE)
		end)
	end
end

function AnimateUI.typeWrite(guiObject, text, delayBetweenChars)
	guiObject.Visible = true
	guiObject.AutoLocalize = false
	local displayText = text

	-- Translate text if possible
	if translator then
		displayText = translator:Translate(guiObject, text)
	end

	-- Replace line break tags so grapheme loop will not miss those characters
	displayText = displayText:gsub("<br%s*/>", "\n")
	displayText:gsub("<[^<>]->", "")

	-- Set translated/modified text on parent
	guiObject.Text = displayText

	local index = 0
	for first, last in utf8.graphemes(displayText) do
		index = index + 1
		guiObject.MaxVisibleGraphemes = index
		wait(delayBetweenChars)
	end
end
return AnimateUI

Or you can see from Animating Text

Can anyone help me so it can be based on team? like if player.Team == Teams[“abcd”] , Thanks.

NOTE : This is for Overhead GUI Billboard, and the animation script is Children of the textlabel that’s why I use script.Parent

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local Storage = game:GetService("ReplicatedStorage")
local Module = Storage:WaitForChild("AnimateUI")
local AnimateUI = require(Module)
local label = script.Parent

AnimateUI.loadTranslator()

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player.Team == Teams:FindFirstChild("Military Police") then
			while Character do
				local message1 = [[Military Police]]
				AnimateUI.typeWrite(label, message1, 0.05)
				task.wait(3)
			end
		elseif Player.Team == Teams:FindFirstChild("Special Reaction Team") then
			while Character do
				local message2 = [[Special Reaction Team]]
				AnimateUI.typeWrite(label, message2, 0.05)
				task.wait(3)
			end
		end
	end)
end)

Like this? I think your issue was not referencing the local player correctly.

local player = game:GetService("Players")

Still doesn’t work. I already try like this

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local Storage = game:GetService("ReplicatedStorage")
local Module = Storage:WaitForChild("AnimateUI")
local AnimateUI = require(Module)
local label = script.Parent

AnimateUI.loadTranslator()

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player.Team == Teams:FindFirstChild("Military Police") then
			while Character do
				local message1 = [[Military Police]]
				AnimateUI.typeWrite(label, message1, 0.05)
				task.wait(3)
				local message2 = [[Special Reaction Team]]
				AnimateUI.typeWrite(label, message2, 0.05)
				task.wait(3)
			end
		end
	end)
end)
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local Storage = game:GetService("ReplicatedStorage")
local Module = Storage:WaitForChild("AnimateUI")
local AnimateUI = require(Module)
local label = script.Parent

AnimateUI.loadTranslator()

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player.Team == Teams:FindFirstChild("Military Police") then
			while true do
				local message1 = [[Military Police]]
				AnimateUI.typeWrite(label, message1, 0.05)
				task.wait(3)
				local message2 = [[Special Reaction Team]]
				AnimateUI.typeWrite(label, message2, 0.05)
				task.wait(3)
			end
		end
	end)
end)

Can I see the names of the teams (screenshot)?


This is the team inside the game.