Tween + trail start to zig zag after a while

After a while, the trail of the bullet starts to zig zag after. Not sure why this is happening…

Before:

After:

-- Function to shoot a projectile using tween
local function shootAt(target,hrp)
	if not target or not target.Parent then return end
	local targetHRP = target if not targetHRP then return end

	local part = shootPartTemplate:Clone()
	ModuleFunctions.CreateTrail(part)
	part.CFrame = CFrame.new(hrp.Position + Vector3.new(0, 2, 0))
	part.Parent = game.Workspace

	-- Distance & travel time
	local distance = (targetHRP.Position - part.Position).Magnitude
	local travelTime = distance / speed

	-- Tween goal (straight to target)
	local tweenInfo = TweenInfo.new(
		travelTime,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out
	)

	local tween = TweenService:Create(part, tweenInfo, {
		Position = targetHRP.Position
	})

	tween:Play()

	-- Cleanup when finished
	tween.Completed:Connect(function()
		if part then
			part:Destroy()
		end
	end)
end

Is it a latency issue?

1 Like

99% latency-related, likely due to the fact you’re using TweenService on the server, which causes parts affected by tweens to stutter.

TweenService should almost always be used exclusively on the client to avoid the latency and reduce load on the server, which shouldn’t be responsible for ephemeral effects such as bullets anyways. You should use a RemoteEvent (or UnreliableRemoteEvent if the bullet visual isn’t important) to create the bullet on the client.

1 Like

Perfect timing. I just finished converting all visual effects to client side instead of it being handled sever side. Which after testing for a little bit the zig zag visual would no longer appear.

You’re correct, it is a latency issue. All the sever will handle now is the damage.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.