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 10 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

01local player = game.Players.LocalPlayer
02local mouse = player:GetMouse() --Getting the player's mouse
03local move = game.Workspace.Move
04 
05mouse.Move:connect(function() --When the mouse moves
06    while true do wait()
07    local target = mouse.Hit
08    if target == nil then
09        return
10    end
11    move.BodyPosition.position = Vector3.new(target)
12    end
13    end)

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 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