So I'm trying to do when my part hits a part it bounces back to the other way but it keeps erroring saying 14:34:46.706 - Workspace.Part.Script:7: attempt to compare number with userdata

Part = script.Parent
BodyVelocity = Part.BodyVelocity

Part.Touched:Connect(function(touch)
	
	if touch.Name == 'Part' then
		if BodyVelocity.Velocity > 0 then
			BodyVelocity.Velocity = Vector3.new(100)
		elseif BodyVelocity.Velocity< 0 then
			BodyVelocity.Velocity = Vector3.new(-100)
		end

	end
end)
	

3 comments

0

That is because Velocity is a Vector3 value. If you want to get the length of the vector you can get it via the Magnitude property.

0

Or going off of what incapax said, you could take an individual value of the Vector3, such as X, Y, or Z.

0

incorrect math on a matrix, learn how to perform math on matrices