Script simply wont work without having "print()"

I dont know whats happening for real, Roblox probably pranking me.

if ill remove print(v) line from script, it wont work.

local healthBars = require(game.ServerStorage.Modules.Healthbar)

local knit = require(game.ReplicatedStorage.Packages.Knit)

local ps = game:GetService("PhysicsService")
local tw = game:GetService("TweenService")
local effectService = knit.GetService("EffectService")

--task.wait(2)

for i,v in pairs(script.Parent:GetChildren()) do
	print(v) -- BUT IF ILL REMOVE THIS LINE IT WONT EVEN WORK
	if v.Name == "HealCrate" then

		local canRotate = true
		local canBreak = true

		coroutine.wrap(function()

			while canRotate do
				local tempTween = tw:Create(v.Box.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {CFrame = v.Box.PrimaryPart.CFrame * CFrame.Angles(90, 90, 0)})
				tempTween:Play()
				tempTween.Completed:Connect(function()
					tempTween:Destroy()
				end)
				task.wait(1)
			end

		end)()

		v.Hurtboxes.Activate.Event:Connect(function(plr)
			if canBreak then
				canBreak = false
				print("break")
				effectService:Effect("All", "Sound", {Sound = game.ReplicatedStorage.Assets.Sounds.IceBreak, Parent = v})

				v.Box.PrimaryPart.ParticleEmitter:Emit()

				local oldTrans = {}
				for _, part in pairs(v.Box:GetChildren()) do
					oldTrans[part] = part.Transparency
					part.Transparency = 1
				end
				task.wait(5)
				canBreak = true
				for _, part in pairs(v.Box:GetChildren()) do
					part.Transparency = oldTrans[part]
				end
			end
		end)
	end
end

Are you sure the script is breaking? Have you tried putting the print after the if, then statement?

local healthBars = require(game.ServerStorage.Modules.Healthbar)

local knit = require(game.ReplicatedStorage.Packages.Knit)

local ps = game:GetService("PhysicsService")
local tw = game:GetService("TweenService")
local effectService = knit.GetService("EffectService")

--task.wait(2)

for i,v in pairs(script.Parent:GetChildren()) do
    print(" ")
	if v.Name == "HealCrate" then

		local canRotate = true
		local canBreak = true

		coroutine.wrap(function()

			while canRotate do
				local tempTween = tw:Create(v.Box.PrimaryPart, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {CFrame = v.Box.PrimaryPart.CFrame * CFrame.Angles(90, 90, 0)})
				tempTween:Play()
				tempTween.Completed:Connect(function()
					tempTween:Destroy()
				end)
				task.wait(1)
			end

		end)()

		v.Hurtboxes.Activate.Event:Connect(function(plr)
			if canBreak then
				canBreak = false
				print("break")
				effectService:Effect("All", "Sound", {Sound = game.ReplicatedStorage.Assets.Sounds.IceBreak, Parent = v})

				v.Box.PrimaryPart.ParticleEmitter:Emit()

				local oldTrans = {}
				for _, part in pairs(v.Box:GetChildren()) do
					oldTrans[part] = part.Transparency
					part.Transparency = 1
				end
				task.wait(5)
				canBreak = true
				for _, part in pairs(v.Box:GetChildren()) do
					part.Transparency = oldTrans[part]
				end
			end
		end)
	end
end

Though it still is printing something, it’s way better than leaking the loop information. If this is a LocalScript, completely scrap it and rerwrite it.

Try to replace print with task.wait

1 Like