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

whats wrong with this 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(BrightBlue, 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 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

The variable TeamColor you use in the fourth line is never defined. I believe you intended it to be the parameter of getTeamMembers. In that case, you need to pass (line 10) (instead of the nil value CGABrown) a BrickColor value, probably BrickColor.new("CGA brown").

So, here is what all of that looks like together:

function getTeamMembers(TeamColor)
    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(BrightBlue, Position)
    for i,v in pairs(getTeamMembers(BrickColor.new("CGA brown"))) do
        repeat wait() until v.Character
        v.Character:MoveTo(-1498.821, 12.499, -277.718)
    end
end


Ad

Answer this question