Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does my name tag script not change the player's team name when they change team?

So what I'm trying to do is make the variable 'lowertext' the player's current team name. But for some reason, when a player changes team, it doesn't change the name tag text. Someone please help, this has been annoying me for a while now lol.

for i, v in pairs(Players:GetChildren()) do
			if v:IsA("Player") then
				lowertext.Text = v.Team.Name
				v.Team:GetPropertyChangedSignal(v.Team):Connect(function()
					for i, v in pairs(Players:GetChildren()) do
						if v:IsA("Player") then
							lowertext.Text = v.Team.Name
						end
					end
				end)
			end
		end

2 answers

✓ Accepted answer

Though I would recommend a Changed event, this for loop is running only once. It needs to run more than once to work. A while wait() do should do the trick.

for i, v in pairs(Players:GetPlayers()) do
	v.Team.Changed:Connect(function()
		lowertext.Text = v.Team.Name
	end)
end

There are many errors in your code and I'm lazy to state all error so here is the fixed code, if its not working feel free to ask me ;)

1 comment

0

You should always state the errors in their code to help them understand why their code is not working, and why the solution works.

This discussion is preserved as it was. New answers, comments, and votes are closed.