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

What's wrong with this script?

Asked by 8 years ago

No errors in the dev tool. When I team myself to the awayteam, my name doesn't show up on the textlabel t1. The text is not there at all, so it is not an issue with updating my playergui. Help?

local bench = game.StarterGui.InfoGui.Frame.ABenchP
local hometeam;
local awayteam;
function GetHome()
    for i, v in pairs(game.Teams:GetChildren()) do
        if v:findFirstChild("home") then
            return v
        end
    end
    return nil
end

function GetAway()
    for i, v in pairs(game.Teams:GetChildren()) do
        if v:findFirstChild("away") then
            return v
        end
    end
    return nil
end



local away = {}
local home = {}

while true do
    wait()
hometeam = GetHome();
awayteam = GetAway();
    local p = game.Players:GetChildren()
    for i = 1,#p do
        if p[i].TeamColor == hometeam.TeamColor then
            table.insert(home,p.Name)
        elseif p[i].TeamColor == awayteam.TeamColor then
            table.insert(away,p.Name)
        end
    end
wait()
end

for i = 1,#away do
    local find = bench:FindFirstChild("t" ..i)
    if find then
        find.Text = away[i]
    end
end

1 answer

Log in to vote
7
Answered by 8 years ago

At line 27, you start an infinite loop that prevents the for loop at line 42 from running.

0
So what do I do with the loop? Ethan_Waike 156 — 8y
2
Just delete the "while true do" at line 27 and the end at line 40 LetThereBeCode 360 — 8y
Ad

Answer this question