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

why won't this script work?

Asked by 9 years ago

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)
0
Don't forget to define the TeamColor for each team.. bbissell 346 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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
0
Technically it would be if isAdmin(player.Name) then bbissell 346 — 9y
0
No, the function takes the Player Instance not the Player's name look closely fw8gw9gw8g 55 — 9y
Ad

Answer this question