Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to Turn CFrame into Vector3?

So I'm experimenting with The Mouse 'Hit' (the CFrame of where the mouse is), and I"m trying to make this one part move by changing the property 'position' in BodyPosition in the block.

I don't know how I can get the CFrame information and put it into a Vector3 format for the 'position' property of BodyPosition

This is the script

local player = game.Players.LocalPlayer
local mouse = player:GetMouse() --Getting the player's mouse
local move = game.Workspace.Move
 
mouse.Move:connect(function() --When the mouse moves
	while true do wait()
	local target = mouse.Hit
	if target == nil then
		return
	end
	move.BodyPosition.position = Vector3.new(target)
	end
	end)
	
	

1 answer

Very simply, the position portion (a Vector3) is stored in the p property of CFrame objects!

In line 11 there, replace Vector3.new(target) with target.p!

Remember, the p is lowercase. Lua is case-sensitive.

This discussion is preserved as it was. New answers, comments, and votes are closed.