Animate Text Label for Overhead GUI

I failed making text label animate for overhead based on team, If i make not based on team it works, but if I make based on team, it doesn’t work
Code 1 (Work, but without based on team)

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()

while true do

local message1 = [[Military Police]]

AnimateUI.typeWrite(label, message1, 0.05)

wait(3)

local message2 = [[Special Reaction Team]]

AnimateUI.typeWrite(label, message1, 0.05)

wait(3)

end

It works, but if i make based on team like :
Code 2 :

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()

while true do
	if Players.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, message1, 0.05)
		wait(3)
	end
end

Or

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()

if Players.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, message1, 0.05)
		wait(3)
	end
end

It doesn’t work, both of it, I also already try do suggestion from forum, but also doesn’t work, here’s the code :

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)
				wait(3)
				local message2 = [[Special Reaction Team]]
				AnimateUI.typeWrite(label, message2, 0.05)
				wait(3)
			end
		end
	end)
end)

This is the 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)
	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 Animate Text
Please anyone can help me to solve it, animate text based on team for overhead gui text label

1 Like

I think you want to check Player.Team, not Players.

Yeah i use Players.Team because I use local Players = game:GetService(“Players”) ?

Okay, to be clear, what does this even do? What is the AnimateUI module? Is it supposed to give a player an overhead GUI depending on what team they are in? If yes, when you do this:

AnimateUI.typeWrite(label, message1, 0.05)

How do you specify which player the GUI is going to be above?