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

How do I switch between CFrame, position, and Vector3 values?

wait(2)
local player = game.Players.LocalPlayer
local character = game.Players.LocalPlayer.Character
local cam = game.Workspace.CurrentCamera
local coframe = cam.CoordinateFrame.p
local lvector = game.Workspace.CurrentCamera.CoordinateFrame.lookVector

character.Archivable = true
charactercopy = character:Clone()
charactercopy.Parent = container
charactercopy:MoveTo(Vector3.new(30,30,30))	

while charactercopy ~= nil do
local lvector = game.Workspace.CurrentCamera.CoordinateFrame.lookVector
local coframe = cam.CoordinateFrame.p
local pos = CFrame.new(lvector*20 + coframe) --hint ben, i only want the position
print(pos) 
--print(lvector)
--print(coframe)
charactercopy:MoveTo(pos)		--20 is how far away from the camera		charactercopy:MoveTo( (lvector*20 + coframe )  )
wait(1)

print(charactercopy.Torso.Position)
end


At line 20, the there is an error "16:29:22.819 - Unable to cast CoordinateFrame to Vector3 16:29:22.820 - Script 'Players.Player1.PlayerGui.LocalScript', Line 20". I need to make the clone move to to the (lvector*20 + coframe) (between the camera and what its looking at. Any help converting coframe and lvector to Vector3 values?

1 answer

✓ Accepted answer

MoveTo takes a Vector3. To convert a CFrame to a Vector3 you use the p property of a CFrame. So just change line 20 to

charactercopy:MoveTo(pos.p)

2 comments

0

ok lemme try

0

THANK YOU 18CWATFORT

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