Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script keeps saying attempt to compare number with user data?

Asked by 5 years ago

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)

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. User#24403 69 — 5y
0
Or going off of what incapax said, you could take an individual value of the Vector3, such as X, Y, or Z. AmWrath 41 — 5y
0
incorrect math on a matrix, learn how to perform math on matrices DeceptiveCaster 3761 — 5y

Answer this question