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

How to Turn CFrame into Vector3?

Asked by 9 years ago

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

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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.

Ad

Answer this question