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

What's wrong with this script?

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

✓ Accepted answer

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

2 comments

0

So what do I do with the loop?

2

Just delete the "while true do" at line 27 and the end at line 40

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