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

issue with this script?

Asked by
Paldi 109
8 years ago

I am having some issues with the part "for i =1,#pplz do" it wont work for some reasons, there is no errors in the output and it only print 1 not 2 or 3

local maps = game.Lighting.Maps:GetChildren()
local pplz = game.Players:GetChildren() 

while true do
if #maps == 0 then                      
    print("No maps found!")  
    script.Parent:remove()                      
    return                              
end 
    wait(3)
    -- add text to a gui saying game will start soon
    chosenmap = maps[math.random(1, #maps)]
    map = chosenmap:Clone()
    map.Parent = game.Workspace.Map
    wait(2)
    local spawn1 = game.Workspace.Map:FindFirstChild(map.Name).Team1:GetChildren()
    local spawn2 = game.Workspace.Map:FindFirstChild(map.Name).Team2:GetChildren()
    local team1 = spawn1[math.random(1, #spawn1)]
    local team2 = spawn2[math.random(1, #spawn2)]
    print "1"
    for i = 1,#pplz do
        if pplz[i].TeamColor == BrickColor.new("Bright red") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
            pplz[i].Character.Torso.CFrame = CFrame.new(team1.Position.x, team1.Position.y+2, team1.Position.z)
            print "2"
        elseif pplz[i].TeamColor == BrickColor.new("Bright blue") and pplz[i] ~= nil and pplz[i].Character:FindFirstChild("Torso") ~= nil then
            pplz[i].Character.Torso.CFrame = CFrame.new(team2.Position.x, team2.Position.y+2, team2.Position.z) 
        end
        print "3"
    end
    wait(10)
    map:remove()
end 

Answer this question