Animation Text Label Based on Team

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

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

This works, but i want to make it base on team
But if i do with
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

end

Or if i use

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
And the script

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

Can anyone help me so it can be based on team? like if player.Team == Teams[“abcd”] , Thanks.
Because like the code above if I use if, it doesn’t work

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

your variables aren’t strings, put them inside these “”

They are strings, they’re just multiline strings.

Where in your code are you getting the player?

You’re trying to access player.Team, but I don’t see where you’re getting the current player. Which you can’t use game.Players.LocalPlayer because it’s a server script, you could do local player = label:FindFirstAncestorWhichIsA("Player") to get the player object and then do your check off that.

Yes but why when i don’t use based on team, i can

Where i use LocalPlayer? I use local player = game:GetService(“Players”)

I should use this? So I can’t use local player = game:GetService(“Players”)?
I’m new to scripting.

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)
		while Character do
			if Player.Team == Teams:FindFirstChild("Military Police") then
				local message1 = [[Military Police]]
				AnimateUI.typeWrite(label, message1, 0.05)
				task.wait(3)
			elseif Player.Team == Teams:FindFirstChild("Special Reaction Team") then
				local message2 = [[Special Reaction Team]]
				AnimateUI.typeWrite(label, message2, 0.05)
				task.wait(3)
			end
		end
	end)
end)
 local player = game:GetService(“Players”)

This just gets the “Players” service not the local player, you can fetch the player instance of any particular player each time “PlayerAdded” is fired inside of a server script as I have done above.

1 Like