Velocity not performing as it's supposed to

So I made this basketball shooting script, and everything was completely fine, but today I was just testing it out and trying to add new stuffs, and then I see that the ball sometimes just don’t reach the desired position that it’s supposed to.

As the video above shows, it’s not even about making the shot or not, the ball just don’t even hit the rim. I don’t know what’s causing it, I had the scripts to print out all the stats that matters with the velocity and the ball’s movement, nothing seems off about those. All I can really think about is that Roblox used to have an issue, I don’t know if it’s implanted on purpose or not, but the par/model/player character will stop moving to a direction if there’s an object that’s in front of him directly.

Btw, the ball is supposed to go in from anywhere, I tried to shoot it from a specific spot in the video, so I can see if there’s any big difference with the stats.

Please anyone help?

Could you show your code that handles the ball shooting?

Here you go, it’s basically egomoose’s script but i added some little stuffs to it

 LaunchBall( c : "Character", StartInCFrame : CFrame , ball : "Ball" , rim : "Hoop" , OffestInCFrame : CFrame )
	
	spawn(function()
	
		local Start = StartInCFrame
		local Rim = rim
		local offset = CFrame.new(0,0,0)
		if OffestInCFrame ~= nil then
			offset = OffestInCFrame
		end
		
		ball.Anchored = true	
		ball.CFrame = CFrame.new(Start.Position,Rim.Position)
				
		local function Pattern01(offsetInCFrame)	

			local X0 = Start.Position

			local Gravity = Vector3.new(0, -workspace.Gravity, 0)

			local End = BallActions.Waypoint( Rim.Position, Color3.fromRGB(255,0,255) )

			End.CFrame = CFrame.new( End.Position, Vector3.new( Start.Position.X, End.Position.Y, Start.Position.Z ) )*offsetInCFrame 

			local magnitude = BallActions.MAGNITUDE(End.Position,Start.Position)

			local T = 0.0141509434*magnitude + 0.3726415094

			print("Magnitude: "..magnitude)

			print("T: "..T)

			local V0 = ( End.Position - X0 - 0.5*Gravity*T*T)/T;
			
			print("V0: ", V0)

			ball.Parent = workspace
			ball.CFrame = CFrame.new(Start.Position,Rim.Position)
			c.HumanoidRootPart.CFrame = CFrame.new(c.HumanoidRootPart.CFrame.p,Vector3.new(Rim.Position.X,c.HumanoidRootPart.Position.Y,Rim.Position.Z))
			ball.CanCollide = true;
			ball.Velocity = V0;	
			ball.Anchored = false;
			wait(.1)
			ball.BelongsTo.Value = '';

		end

		Pattern01(offset)
		
	end)

I suggest you use ball.AssemblyLinearVelocity as Velocity is deprecated and not end lines with ;


Maybe it’s a network ownership issue? Try doing

ball:SetNetworkOwner(nil)

after setting Anchored to false.

You should use coroutine.wrap because spawn can unexpectedly yield.

coroutine.wrap(function()
    --code
end)() --remember double brackets at end!
2 Likes

Wait, my guy! You’re a genius! I fixed it by setting the network owner to nil. Thank you so much! <3

1 Like