What do you want to achieve? !
This script assigns 4 players to their own separate team once it has detected that the round is starting,
What is the issue?
The script is stopped by this error:
(Line 21: invalid argument #2 (string expected, got instance)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I changed line 21 from
player.Team = game:GetService(“Teams”)[Mint].Name
to
game.Players[player].Team = game:GetService(“Teams”).Mint.Name
--max players is 1.
local START = game.Lighting.roundstart
local MaxPlayers = game.Lighting.MaxPlayers
START.Changed:Connect(function()
local Mint = game.Teams.Mint
local Violet = game.Teams.Violet
local Cocoa = game.Teams.Cocoa
local Royal = game.Teams.Royal
local plrs = {}
for i, player in pairs (game.Players:GetPlayers()) do
if player then
local MintCount = Mint:GetPlayers()
if #MintCount >= MaxPlayers.Value then
print ("loading")
else
game.Players[player].Team = game:GetService("Teams").Mint.Name
end
local VioletCount = Violet:GetPlayers()
if #VioletCount >= MaxPlayers.Value then
print ("loading")
else
game.Players[player].Team = game:GetService("Teams").Violet.Name
end
local CocoaCount = Violet:GetPlayers()
if #CocoaCount >= MaxPlayers.Value then
print ("loading")
else
game.Players[player].Team = game:GetService("Teams").Cocoa.Name
end
local RoyalCount = Royal:GetPlayers()
if #RoyalCount >= MaxPlayers.Value then
print ("loading")
else
game.Players[player].Team = game:GetService("Teams").Royal.Name
end
end
end
end)