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

why won't this script work?

i don't get any error in the output and the teams never show up.

admins={"Threatboy101","vinothpizza555"}
game.Players.PlayerAdded:connect(function(player)
	if admins[player.Name]then
        player.Chatted:connect(function(msg)
            if string.sub(msg,1,6)==":Teams"then
	              repeat wait() until
	              teams ==game:GetService("Teams") -- A variable for teams
                  blue =Instance.new("Team", teams) -- The new team
                  blue.Name = "BLUE" -- The team's name is "Sup"
                  red =Instance.new("Team", teams)
                  red.Name="RED"
               print("yay")
             end
 
      end)
  end
end)

1 comment

0

Don't forget to define the TeamColor for each team..

1 answer

This line:

if admins[player.Name]then

Returns the item in the table with the key, player.Name and not the item in the table with the value of, player.Name

You would instead need to loop through the table to find the value

local admins = {"Player1", "Player2"}

function isAdmin(player)
	for index, value in pairs(admins) do
		if player.Name:lower() == value:lower() then
			return true
		end
	end
end

Add that function into your script then replace the part that says:

if admins[player.Name]then

with

if isAdmin(player) then

2 comments

0

Technically it would be if isAdmin(player.Name) then

0

No, the function takes the Player Instance not the Player's name look closely

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