local part1 = script.Parent.Head -- the part that will be rotated holding the weld
local part2 = game.Workspace:WaitForChild("FacePart") -- the destination part
local weld = part1:FindFirstChild("Base") -- the weld we will rotate
local direction = (part2.Position - part1.Position).unit
local angle = math.atan2(direction.x, direction.z)
weld.C0 = CFrame.fromEulerAnglesXYZ(0, angle, 0) * weld.C0
So I’m trying to rotate a part’s weld so that the part can face another part on the map.
I can’t seem to get it to face the direction of “Part2”
local base = script.Parent.Base
local weld0 = base.Head
local xy = Vector3.new(1, 0, 1)
local y = Vector3.yAxis
local targetCF = CFrame.new()
local find = workspace:WaitForChild("FacePart")
local look0 = CFrame.lookAt(base.Position, (find.Position * xy) + (base.Position * y))
targetCF = base.CFrame:ToObjectSpace(look0):Inverse()
weld0.C1 = targetCF