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
That is because
Velocityis a Vector3 value. If you want to get thelengthof the vector you can get it via theMagnitudeproperty.Or going off of what incapax said, you could take an individual value of the Vector3, such as X, Y, or Z.
incorrect math on a matrix, learn how to perform math on matrices