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

whats wrong with my script?

Asked by
ned995 0
10 years ago
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

0
Press F9 and tell us the errors. If none, I would say that you should use CFrame insted of MoveTo. Nickoakz 231 — 10y

1 answer

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

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
Ad

Answer this question