Projectile Lagging

For my basketball shooting system, the ball sometimes lags whenever it’s moving.

Here’s a video of the problem:

Here is my code for cloning the ball and making it move:

local ball = character.Ball

local newBall = ball:Clone()

--This is all random mumbo jumbo for the shot meter don't worry about this--

local arc = 0.8
local adjust = (distance / 10)

local neg = math.random(1, 2)
local add

if neg == 1 then

	add = Vector3.new(-(adjust - (releaseTime.Value * adjust)), 0, (adjust - (releaseTime.Value * adjust)))

elseif neg == 2 then

	add = Vector3.new((adjust - (releaseTime.Value * adjust)), 0, -(adjust - (releaseTime.Value * adjust)))
end

local target = workspace.Basket.Position + add

local gravity = Vector3.new(0, -game.Workspace.Gravity, 0)
local x0 = character.HumanoidRootPart.CFrame * Vector3.new(0, 2, -2)

local v0 = ((target - x0 - 0.5 * gravity * arc * arc) / arc)

--Cloning the ball--

local newBall = newBall:Clone()
newBall.Velocity = v0
newBall.CFrame = CFrame.new(x0)
newBall.CanCollide = true
newBall.Parent = workspace

newBall:SetNetworkOwner(nil)
1 Like

Looks like the ball lags when it transfers NetworkOwnership from the player to the server.
Search up how to set the ownership to the server before it’s thrown.

1 Like

I found out the issue. I set the network owner to the client and it actually made everything so much smoother.

1 Like

The issue with that is that if you have more than one player the ball will lag for the other players.
The ball will be created on the player’s client, replicated to the server, then back to the other player’s client, which causes a little more lag for them.

1 Like

Oh yeah, I just realized that. Well I’ve tried setting the network owner right after I clone the ball and parent it to the workspace. But that doesn’t work.

Check to see if the ownership switches back to the player when they interact with it. That’s what’s normally supposed to happen.
I just did a quick search using ‘make a ball not lag’ and found a few solutions.