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

part not moving when setting cframe?

local partb = script.Parent
local parta = game.Workspace:WaitForChild("PartA")


partb.CFrame = partb.CFrame + parta.CFrame.lookVector * 2

there arent any output errors yet the part doesnt move to the position i want, and i cant find a problem with this incredibly easy code

1 comment

0

Dumb Question : D

1 answer

✓ Accepted answer

For translation, you use CFrame * CFrame

Also, lookVector is a Vector3 value. To move a CFrame by Vector3, you would do

CFrame * CFrame.new(Vector3)

partb.CFrame = partb.CFrame * CFrame.new(parta.CFrame.lookVector * 2)

4 comments

0

it still doesnt work, i dont see whats the problem

0

It should. I've tested it and it moves one brick in the direction that the other is facing. Maybe it stops before getting to the line. Is this the whole script? Because if it is, then maybe "PartA" doesn't exist.

0

its the whole script, and ive been playing around with it trying to make it work, ive been able to move parta cframe but only realtive to global space and not infornt of part b. i dont see why this isnt working

0

Are you trying to move PartB in front of part A? The script moves PartB in the direction that PartA is facing. To move it in front of PartA, you would do partb.CFrame = parta.CFrame * CFrame.new(parta.CFrame.lookVector * 2)

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