Raycasting parts at different intervals

I am attempting to create a fireball effect that is created when player activates their sword.

See below.

image

As seen, the blaze shoots out multiple flames at different seconds.

I tried to attempt this with my code, but it still does not replicate the same behaviour.

function fireAbility()
	tickB = tick();
	local mouseloc = uis:GetMouseLocation()
	local origin = camera:ViewportPointToRay(mouseloc.X, mouseloc.Y)
	local raycastparams


	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Name ~= Player.Name then
			table.insert(IgnoreList, v)
			local character = v.Character
			ignoreAccessories(character)



			raycastparams = RaycastParams.new() 
			raycastparams.FilterDescendantsInstances = {IgnoreList}
			raycastparams.FilterType = Enum.RaycastFilterType.Include;

			local handPosition = Sword:WaitForChild("Handle").Position
			local direction = (mouse.Hit.Position - handPosition).Unit * 30
			local ray = workspace:Raycast(origin.Origin, origin.Direction * 1000, raycastparams)

			local part = Instance.new("Part")
			part.Anchored = true
			part.CanCollide = false 
			part.Position = origin.Origin + (origin.Direction.Unit * 5)
			part.Parent = workspace
			part.Size = Vector3.new(1,1,1)

			local part2 = Instance.new("Part")
			part2.Anchored = true
			part2.CanCollide = false
			part2.Position = origin.Origin + (origin.Direction.Unit * 5)
			part2.Parent = workspace
			part2.Size = Vector3.new(1,1,1)

			local part3 = Instance.new("Part")
			part3.Anchored = true
			part3.CanCollide = false
			part3.Position = origin.Origin + (origin.Direction.Unit * 5)
			part3.Parent = workspace
			part3.Size = Vector3.new(1,1,1)


			local tweenInfo = TweenInfo.new(
				0.6, -- Time
				Enum.EasingStyle.Linear, -- EasingStyle
				Enum.EasingDirection.Out, -- EasingDirection
				0, -- RepeatCount (when less than zero the tween will loop indefinitely)
				false, -- Reverses (tween will reverse once reaching it's goal)
				0 -- DelayTime
			)

			local tweenInfo2 = TweenInfo.new(
				1.5, -- Time
				Enum.EasingStyle.Linear, -- EasingStyle
				Enum.EasingDirection.Out, -- EasingDirection
				0, -- RepeatCount (when less than zero the tween will loop indefinitely)
				false, -- Reverses (tween will reverse once reaching it's goal)
				0 -- DelayTime
			)


			local tweenInfo3 = TweenInfo.new(
				1, -- Time
				Enum.EasingStyle.Linear, -- EasingStyle
				Enum.EasingDirection.Out, -- EasingDirection
				0, -- RepeatCount (when less than zero the tween will loop indefinitely)
				false, -- Reverses (tween will reverse once reaching it's goal)
				0 -- DelayTime
			)

			local tween = TweenService:Create(part, tweenInfo, { Position = origin.Origin + (origin.Direction.Unit) * 50})

			local tween2 = TweenService:Create(part2, tweenInfo2, { Position = origin.Origin + (origin.Direction.Unit) * 50})
			local tween3 = TweenService:Create(part3, tweenInfo3, { Position = origin.Origin + (origin.Direction.Unit) * 50})

			tween:Play()
			tween2:Play()
			tween3:Play()


My attempt below:

It’s because you’re playing all of the tweens at the same time, add some waits in between or smth

tween:Play()
task.wait(1)
tween2:Play()
task.wait(1)
tween3:Play()

it’s because they aren’t using single raycast, but many, see you should create point every 3-4 studs in this case depending on speed and then check, on client you can simply lerp between those points and achieve smooth effect

Sorry for getting back to you so late. I tried this now, I can’t seem to get the desired effect. If I lerp the new part to the ray, the part will only be infront of my camera where I have clicked.

Could you provide a code snippet to help me understand what you mean?

thanks

You don’t lerp anything on server, only cast rays, also code will look like this:

repeat
    local direction = currentPoint + Vector3.new(0,0,-3) -- add your direction

    -- code to raycast ect.

    currentPoint = nextPoint
until Hit or time > exhausted