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.

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

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

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