How do I make Motor6D’s attached part be faced to another part? (something like Team Fortress 2 sentry)
Sentry has a Humanoid and a Torso anchored (this doesnt seem to change anything, though)
I have tried to do it through CFrame.lookAt. It somewhat works at first frame, but then only follows the target very, very briefly.
The current code I have:
local Character = script:FindFirstAncestorOfClass("Model") --Sentry model
local Attacking = workspace.Part -- This is for an example, Attacking varies in the rest of a script
game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
Character.Head.Neck.C0 = CFrame.lookAt(Character.Head.Neck.C0.Position,
Attacking.PrimaryPart.Position) * CFrame.Angles(math.rad(-90), 0, math.rad(-90))
end)
Things I tried (and they obviously didnt work):
- Setting CFrame.lookAt to a Part and not Motor6D (turret starts jumping like crazy)
- Setting C1 instead of C0 (no result)
- Setting Head Position in CFrame.lookAt instead of Character.Head.Neck.C0.Position (sentry loses its head l el)