You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make this loop ends when the LineDrawer is gone. -
What is the issue? Include screenshots / videos if possible!
It doesn’t end even though. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to put conditions and use any kinds of loop (of course not the for - loop) but it stills continues even when the part was destroyed. I looked up some posts on DevForum and it doesn’t help me much with this problem.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Module.MainLine = function(Humr, MousePos)
local SP = Humr.Position + Humr.CFrame.LookVector * 5
local MidP = (Humr.CFrame.LookVector * 20) + Vector3.new(0, 120, 0)
local LineDrawer = Instance.new("Part")
LineDrawer.Name = "LineDrawer"
LineDrawer.Position = SP
LineDrawer.Size = Vector3.new(1, 1, 1)
LineDrawer.CanCollide = false
LineDrawer.Anchored = true
LineDrawer.Transparency = 0
LineDrawer.Parent = workspace
task.spawn(function()
while LineDrawer ~= nil do
task.wait()
local NewBall = Ball:Clone()
local RotateX = math.rad(RD:NextInteger(-180, 180))
local RotateY = math.rad(RD:NextInteger(-180, 180))
local RotateZ = math.rad(RD:NextInteger(-180, 180))
NewBall.CFrame = LineDrawer.CFrame * CFrame.Angles(RotateX, RotateY, RotateZ)
NewBall.Parent = workspace
end
end)
for i = 0, 1, .01 do
task.wait(.01)
local Quad = BrezierModlue.QuadBrezier(i, SP, MidP, MousePos)
LineDrawer.Position = Quad
end
LineDrawer:Destroy()
end
I had many problems when working on with other loops (not for - loop), so thank you if you can correct me.