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

Moving a Character !Help!

Asked by 9 years ago
local character = script.Parent.Parent.Character
local player = game.Players.LocalPlayer

local cam = game.Workspace.CurrentCamera
local coframe = cam.CoordinateFrame.p
local lvector = game.Workspace.CurrentCamera.CoordinateFrame.lookVector
--local focus = cam.Focus  --cant do because it has x,y,z,  r,o,t,a,t,i,o,n

-- attempt to find a container; create a new one if it doesn't exist
local container = Workspace:FindFirstChild("LocalBin")
if not container then
    container ="Camera")
    container.Name = "LocalBin"
    container.Parent = Workspace

local character = game.Players.LocalPlayer.Character
character.Archivable = true
charactercopy = character:Clone()
charactercopy.Parent = container

while charactercopy ~= nil do
local lvector = game.Workspace.CurrentCamera.CoordinateFrame.lookVector
local coframe = cam.CoordinateFrame.p
charactercopy:MoveTo(*20 + coframe))     --20 is how far away from the camera        charactercopy:MoveTo( (lvector*20 + coframe )  )

I am trying to make a script that the character stays between the camera and where its looking. When I get to line 30 , (*20 + coframe)) The copy just stays at 0,0,0 even though I keep on updating the lvector and coframe. How would I do this?

1 answer

Log in to vote
Answered by
Dom2d2 35
9 years ago

Your question is somewhat confusing, but I will try to help. Remember that with Vector3, there must be three numbers. In this line:

charactercopy:MoveTo(*20 + coframe)) 

You only good 2 numbers, lvector*20 is one number, and coframe is another number. You'll need a third coordinate to complete this, because it uses Vector3.


Answer this question