Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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.

01for i, v in pairs(Players:GetChildren()) do
02            if v:IsA("Player") then
03                lowertext.Text = v.Team.Name
04                v.Team:GetPropertyChangedSignal(v.Team):Connect(function()
05                    for i, v in pairs(Players:GetChildren()) do
06                        if v:IsA("Player") then
07                            lowertext.Text = v.Team.Name
08                        end
09                    end
10                end)
11            end
12        end

2 answers

Log in to vote
1
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
1for i, v in pairs(Players:GetPlayers()) do
2    v.Team.Changed:Connect(function()
3        lowertext.Text = v.Team.Name
4    end)
5end

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

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. deeskaalstickman649 475 — 4y

Answer this question