AssemblyLinearVelocity returning "nan, nan, nan"

I’m trying to get the move direction if a ball and it keeps giving nan nan nan whenever I make a variable for it. Does anyone know how to fix this? Thanks

bullet.Touched:Connect(function(hitted)
		if hitted.Parent:FindFirstChild("Humanoid") or hitted:IsDescendantOf(tool) or hitted.Parent == nil or hitted.Name == "Paint" then return end
	local vectorSpot, CFspot = bullet.Position, bullet.CFrame
	local velocityDir = hitted.AssemblyLinearVelocity.Unit
	print(velocityDir)--this prints nan, nan, nan
	bullet:Destroy()		
end)

this happens if the velocity is 0. it tries to divide 0 by 0 when getting the unit vector and you end up with nan.

you have to check if the velocity magnitude is greater 0 and then get its unit vector

Ohhh, you’re right. I accidentally used hitted.AssemblyLinearVelocity instead of bullet.AssemblyLinearVelocity. Thanks!

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