Ok, so here is my issue, I’ve created some tanks, and I’ve got it so i t can aim at the the mouse position, but i only want one part to turn left/right, and the other up and down, here is a video demonstrating what i mean:
And here is my code
Client:
--[ VARIABLES ]--
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
--[ SERVICES ]--
local UserInputService = game:GetService("UserInputService")
--[ MAIN ]--
while true do
wait(0.001)
game.ReplicatedStorage.TankTurretEvent:FireServer(Mouse.Hit.Position, Mouse.TargetFilter)
end
Server:
game.ReplicatedStorage.TankTurretEvent.OnServerEvent:Connect(function(Player, MouseHit, TargetFilter)
local LookAtX = CFrame.lookAt(script.Parent.Turret.PrimaryPart.Position, MouseHit)
local Lerp = script.Parent.Turret.PrimaryPart.CFrame:Lerp(LookAtX, 0.010)
script.Parent.Turret:SetPrimaryPartCFrame(Lerp)
end)
Thanks for the reply, and sorry for my late response, the solution does the trick, some parts can only aim on XZ/ and some Y, but it seems to change the orientation of the parts, or face the opposite direction all together sometimes: