I'm trying to teleport in front of the block, not on top of it. I figured lookVector would be the way to go because it it the direction the block is facing. However I'm not very experienced in using it. Am I doing this wrong? Everything is defined, exists, etc.
for _,v in pairs(workspace.Bricks:GetChildren()) do if v.Name == "GreenBrick" then if v.CanTeleport.Value == true and v ~= script.Parent then print(v.CFrame.lookVector) char:MoveTo(v.Position * v.CFrame.lookVector) end end end
The :MoveTo method automatically detects collisions in moving, and tries to put the moved model in the topmost unoccupied space. You must be trying to move your model somewhere inside something, which cause MoveTo to put your model on top of the part instead.
v.Position * v.CFrame.lookVector
doesn't really mean anything unless you're specifying the origin is for some reason very important.
You probably want to add them -- v.Position + 5 * v.CFrame.lookVector* would be 5 studs away from
v.Positionin the direction of
v.CFrame.lookVector`.
As per iconmaster's suggestion, you shouldn't use :MoveTo
if you want it to be exactly at this position. Instead, you should set the CFrame
of the thing you're moving (presumably char
is a Character and you'd set the .CFrame
of the Torso)