Why is my script not working?

Im trying to make a script that spawns a Fire Ball, the fireball will then travel to a certain area and then despawn. None of this is working through and there are no errors in the output that I can find, I tried to debug it but that didn’t help as all It did was still do nothing but print at the end of the lines of code.

Can anyone help me?

Script

local RS = game:GetService("ReplicatedStorage")

local FB = RS:WaitForChild("FireBall")

while true do
	task.wait(0.5)
	print("1")
	
	local NEWFB = FB:Clone()
	NEWFB.Anchored = true
	NEWFB.Parent = game.Workspace
	NEWFB.Position = script.Parent.Position + Vector3.new(0,0,5)
	
	print(2)
	for i = 1,80 do
		NEWFB.Position = NEWFB.Position + Vector3.new(0,0,1)
	end
	
	print(3)
	
	NEWFB:Destroy()
end

There is no delay in your for loop meaning it will visually instantly snap every 0.5 seconds, And since you’re deleting it after it snaps to the final position and then deleting it, To you it just looks like it’s re-appearing and disappearing in the same spot when in reality it’s just looping at a fast rate that you can’t see it changing.
I recommend learning FastCast, alternatively learn the importance of using bodyposition/tweenservice with attack moves. Alternatively if you are sure this is what you want to do you need to add a task.wait(amnt) in-between each iteration in your for loop.

2 Likes