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

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

Asked by 10 years ago
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

Log in to vote
2
Answered by
User#2 0
10 years ago

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)
0
ok lemme try tkddude2 75 — 10y
0
THANK YOU 18CWATFORT tkddude2 75 — 10y
Ad

Answer this question