Help with :ToObjectSpace()/:VectorToObjectSpace()

I’m currently making a dodge system and I want the player to only be able to dodge left/right/up/down and I can’t figure out how to get the vector directions to goto object space, without object space and currently the dodges only go in the directions of the world space vectors.

Code for the velocity direction:

DashVelocity.Velocity = Character.HumanoidRootPart.CFrame:VectorToObjectSpace(Vector3.new(0, 0, 1)) * 50
-- Code for the other directions are the same besdies the vector point

GIF of vectors being stuck on world space:

If anyone knows a way to get the directions working in object space or a better way to do this completely please tell me.

4 Likes
local angle = 0 -- (degrees) change to which direction you want. 0 degrees means it will go in front

DashVelocity.Velocity = (Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(angle), 0)).LookVector * 50

I already fixed the problem, the way I fixed it was by using world space not object space. Didn’t give myself the solution cause don’t think thats a good idea.

1 Like