• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


08 Jan, 2025

Updated at 20 Jan, 2025

Script isn't stopping

The script SOMEHOW isn’t breaking or stopping. It just prints “ACTIVE” all the time and it always works even if the objects don’t exist.

Help!

for _, child2 in ipairs(child:GetChildren()) do
			if string.match(child2.Name, "CannonProperty_") then
				if not child:FindFirstChild("CannonApplied_" .. string.sub(child2.Name, 16, 99999)) then
					local side = string.sub(child2.Name, 16, 99999)
					local bool = Instance.new("BoolValue")
					bool.Parent = child
					bool.Name = "CannonApplied_" .. side
					--print(side)
					coroutine.wrap(function()
						while task.wait() do
							print("ACTIVE")
							if not child then print("STOPPED") break end
							if not child2 then print("STOPPED") break end
							if child:FindFirstChild("CannonProperty_" .. side) then
								if side == "Right" and child and child2 then
									local leftDirection = Vector3.new(-1, 0, 0)
									child.AssemblyLinearVelocity = leftDirection * -child2.Value
									task.wait(0.1)
								elseif side == "Left" and child and child2 then
									local leftDirection = Vector3.new(1, 0, 0)
									child.AssemblyLinearVelocity = leftDirection * child2.Value
									task.wait(0.1)
								elseif side == "Front" and child and child2 then
									local leftDirection = Vector3.new(0, 0, 1)
									child.AssemblyLinearVelocity = leftDirection * -child2.Value
									task.wait(0.1)
								elseif side == "Back" and child and child2 then
									local leftDirection = Vector3.new(0, 0, -1)
									child.AssemblyLinearVelocity = leftDirection * child2.Value
									task.wait(0.1)
								elseif side == "Top" and child and child2 then
									local leftDirection = Vector3.new(0, 1, 0)
									child.AssemblyLinearVelocity = leftDirection * child2.Value
									task.wait(0.1)
								elseif side == "Bottom" and child and child2 then
									local leftDirection = Vector3.new(0, -1, 0)
									child.AssemblyLinearVelocity = leftDirection * -child2.Value
									task.wait(0.1)
								else
									print("AAAAAA")
								end
							else
								break
							end
						end	
					end)()
				end
			end
		end

1 post - 1 participant

Read full topic