How do I make this loop stop, then play every few seconds? Can someone fix this script?
local amount = 1000
local person = script.Parent.Parent
local cam = game.Workspace.CurrentCamera
repeat wait() until game.Workspace:findFirstChild(person.Name)~=nil
repeat wait() until game.Workspace:findFirstChild(person.Name):findFirstChild("Head")~=nil
local theperson = game.Workspace:findFirstChild(person.Name)
local head = game.Workspace:findFirstChild(person.Name):findFirstChild("Head")
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Transparency = 0.5
part.BrickColor = BrickColor.new("Pastel light blue")
part.TopSurface = "Smooth"
part.BottomSurface = "Smooth"
part.formFactor = "Custom"
part.Size = Vector3.new(.2,1.2,.2)
local mesh = Instance.new("BlockMesh")
mesh.Scale = Vector3.new(.4,2,.4)
mesh.Parent = part
while true do
for i = 1, amount do
local drop = part:Clone()
drop.Parent = cam
drop.CFrame = cam.CoordinateFrame *CFrame.new(math.random(-50,50),math.random(80,110),math.random(-50,50))
drop.Anchored = false
You can have a control variable outside of the loop like for example called paused and then in the loop you can have all of that loop code wrapped in an if which checks too see if paused isnt true and if it is then set it to false every few seconds
Soo, the problem is, you can’t stop the loop and then restart it without restarting loop from start, but if we have while loop, that have if condition inside of it, you can change condition to false, soo while loop will run, but the condition wiill block the function, then if you wan’t, set the value to true and then loop start, if you wan’t to break loop, set the main condition to false, soo loop will break permanently