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

part not moving when setting cframe?

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

0
Dumb Question : D matthew2017_2019 -5 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

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)
0
it still doesnt work, i dont see whats the problem deerdharok 91 — 6y
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. UgOsMiLy 1074 — 6y
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 deerdharok 91 — 6y
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) UgOsMiLy 1074 — 6y
Ad

Answer this question