Tower Projectile Script not working at line 20

while task.wait(0.001) do
	if script.Parent.Triggered.Value == true then
		
	
	
	local high = 0
	local low = 999999999999
	local enemy = script.Sort
	local enemies = workspace.Enemies
	local waitTime = 0.01 -- time to wait, in seconds

	-- create a new task
	
	


	
	
	for i, v in pairs(enemies:GetChildren()) do
		local distance = (v.Torso.Position - script.Parent.OriginalBall.Value.Position).Magnitude
		if distance < 12 then
			v.Zombie =- 35
			print(v.Zombie.Name)	
			script.Parent.ExplosionEffect.Enabled = true
			script.Parent.Transparency = 1
		end	
			
		script.Parent.ExplosionEffect.Enabled = true
		script.Parent.explode:Play()
		print('explosionradius')
		task.wait(1)
		script.Parent.ExplosionEffect.Enabled = false
		script.Disabled = true
		task.wait(0.05)
		script.Parent:Destroy()
		end
	
		
	end
end


	
	


explode2
whats wrong with the script? i don’t get it.

What’s in the OriginalBall.Value ? If it’s an object then it’s probably being declared from the client and checked on the server. You should declare it from the server.

Does that error occur every time?
I think it is because you are disabling the script in a previous iteration of the loop

script.Disabled = true

script.Parent:Destroy()


@dmnksz, the error is saying that script.Parent is nil, not OriginalBall

I am guessing it probably works once and then stops at the second iteration. The issue is that you are destroying “script.Parent” in your last line, yet when it iterates in the for loop again, on the “distance” variable, it is trying to call “script.Parent” again, except script.Parent is now nil because it has been destroyed in the previous iteration.

I am not sure what you are precisely trying to do, but what you could do to try fixing it is take this bit of your code

task.wait(0.05)
script.Parent:Destroy()

and move it right before the last “end” (basically right after the for loop). Try to see what it does when you do that.