so in the script in the script i did this, it printed gamestart but didn't print yes, the rest of the script works just that this for loop doesn't work
while true do num = nil print ("gamestart") for _,i in pairs(game.Players:GetPlayers())do print ("yes") if i.CanPlay.Value == true then print ("canplay") if num == nil then num = 0 end num = num+1 local Number = Instance.new("IntValue") Number.Parent = i Number.Name = ("PlateNumber") Number.Value = num print ("done") for _,o in pairs(game.Workspace:GetChildren())do print ("getting character") if o.Name == i.Name then print ("got character") if num == 1 then o.HumanoidRootPart.CFrame = CFrame.new(BP1.X,BP1.Y+4,BP1.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP1.X,BP1.Y,BP1.Z) end if num == 2 then o.HumanoidRootPart.CFrame = CFrame.new(BP2.X,BP2.Y+4,BP2.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP2.X,BP2.Y,BP2.Z) end if num == 3 then o.HumanoidRootPart.CFrame = CFrame.new(BP3.X,BP3.Y+4,BP3.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP3.X,BP3.Y,BP3.Z) end if num == 4 then o.HumanoidRootPart.CFrame = CFrame.new(BP4.X,BP4.Y+4,BP4.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP4.X,BP4.Y,BP4.Z) end if num == 5 then o.HumanoidRootPart.CFrame = CFrame.new(BP5.X,BP5.Y+4,BP5.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP5.X,BP5.Y,BP5.Z) end if num == 6 then o.HumanoidRootPart.CFrame = CFrame.new(BP6.X,BP6.Y+4,BP6.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP6.X,BP6.Y,BP6.Z) end if num == 7 then o.HumanoidRootPart.CFrame = CFrame.new(BP7.X,BP7.Y+4,BP7.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP7.X,BP7.Y,BP7.Z) end if num == 8 then o.HumanoidRootPart.CFrame = CFrame.new(BP8.X,BP8.Y+4,BP8.Z) Base = game.Workspace.original:Clone() Base.Parent = workspace Base.Name = "BasePlate" Base.Locked = false Base.CFrame = CFrame.new(BP8.X,BP8.Y,BP8.Z) end end end end end wait(20) for _,i in pairs(game.Workspace:GetChildren())do print ("getting BasePlate") if i.Name == "BasePlate" then print ("got BasePlate") i:Destroy() end for _,i in pairs(game.Players:GetChildren())do print ("getting players 2") if i.CanPlay.Value == true then print "canplay 2" for _,e in pairs (game.Workspace:GetChildren())do print ("getting character 2") if e.Name == i.Name then print ("got character 2") e.HumanoidRootPart.CFrame = CFrame.new(500, 4, 500) end end for _,o in pairs (i:GetChildren())do print ("getting platenumber") if o.Name == "PlateNumber" then print ("destroying patenumber") o:Destroy() end end end wait (20) end end end
it outputs:
gamestart getting BasePlate getting players 2 canplay 2 getting character 2 (x14) got character 2 getting platenumber (x6)
The script get trapped inside the loop. In order to get out of it, you need a break at the bottom of your loop. Here's an example of this:
while true do wait() print("hi") end --will get stuck above print("done")
OUTPUT: "hi"
note that it would print an infinite amount of times
and with a break:
while true do wait() print("hi") break end print("done")
OUTPUT: "hi", "done"
the wait at the end was mispaced looping the for loop too many times