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

whats wrong with my script?

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

1 comment

0

Press F9 and tell us the errors. If none, I would say that you should use CFrame insted of MoveTo.

1 answer

✓ Accepted answer

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

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