function getTeamMembers(CGABrown) local members = {} for i,v in pairs(Game.Players:GetPlayers()) do members[#members+1] = v.TeamColor == TeamColor and v or nil end return members end function teleportTeam(CGABrown, Position) for i,v in pairs(getTeamMembers(CGABrown)) do repeat wait() until v.Character v.Character:MoveTo(-1498.821, 12.499, -277.718) end end
I think you have the wrong idea of how to use parameters in function declarations. This is probably what you were going for. Also, if you want to put in the name, you have to use the Name
property of BrickColor
. Another thing is MoveTo
takes a Vector3
as a parameter, so you need to give it a Vector3
value rather than three separate coordinates.
function getTeamMembers(tColor) local members = {} for i,v in pairs(Game.Players:GetPlayers()) do members[#members+1] = v.TeamColor.Name == tColor and v or nil end return members end function teleportTeam(tColor, x, y, z) for i,v in pairs(getTeamMembers(tColor)) do repeat wait() until v.Character v.Character:MoveTo(Vector3.new(x, y, z)) end end -- usage teleportTeam("CGABrown", -1498.821, 12.499, -277.718) -- note the double quotes ("") for _, plr in pairs(getTeamMembers("CGABrown")) do print(plr.Name .. " is on CGABrown") end