Is there a way to get A CFrame from a Vector3? [SOLVED]

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making skill for my game which will make you jump into the air and land back on to your cursor position

  2. What is the issue? Include screenshots / videos if possible!
    well using cursor position will give you a Vector3 value so when I tweened it to make it land at the position only the HumanoidRootPart moved and not the other parts of the body (On the server) It works fine with tweening CFrame but not with the position

Client

Server

The Video
https://streamable.com/f711fi

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried searching but nothing was founded

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

if plr:DistanceFromCharacter(pos) <= 100 then
			goal = {}
			goal.Position = pos + Vector3.new(0,3,0)
		else
			goal = {}
			goal.CFrame = mainchar.HumanoidRootPart.CFrame * CFrame.new(0,-25,-8)
		end
		
		local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Quad, 
			Enum.EasingDirection.In, 0, false, 0)
		
		local tween = TweenService:Create(part, tweenInfo, goal)
		
		tween:Play()

so if the cursor is out of 100 studs it will land in front as you can see

1 Like
local position = cursor.Position

local vectorToCframe = CFrame.new(position.X, position.Y, position.Z)

This should work. Make sure to define the cursor.

1 Like

You can just do;

local position = cursor.Position

local vectorToCframe = CFrame.new(position)
2 Likes

The reason why I did pos.X Y and Z is because it is easier to see where the numbers are coming from.

now the server and the client are the same but the Hmnrp keep pointing at one direction. Is there anyway to fix that?

Oh, to fix that you need to use this.

local position = cursor.Position

local vectorToCframe = CFrame.lookAt(position, position + player.Character.HumanoidRootPart.CFrame.LookVector)

You could use CFrame.lookAt

@Tommybridge has a good way of doing this.

I don’t think it returns a direction? It just replaces CFrame.new(pos, lookAt) which is deprecated.

1 Like