So I wanna make a turret that moves to face a players mouse so I did:
wait(5)
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Tank = game.Workspace:FindFirstChild(""..Plr.Name.."'s_Tank")
local mousePosition = script.Parent.GetMousePosition.MousePosition
local FakeTurret = Tank.FakeTurretHitbox
while wait() do
FakeTurret.CFrame = CFrame.new(FakeTurret.CFrame.p, mousePosition.Value.p)
end
This worked but I only wanted the turret to move to the target on it's y axis, so I did this:
wait(5)
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Tank = game.Workspace:FindFirstChild(""..Plr.Name.."'s_Tank")
local mousePosition = script.Parent.GetMousePosition.MousePosition
local FakeTurret = Tank.FakeTurretHitbox
while wait() do
local cframe = CFrame.new(FakeTurret.CFrame.p, mousePosition.Value.p)
cframe.x = 0
cframe.z = 0
FakeTurret.CFrame = cframe
end
This didn't work though, the output said "18:43:42.868 - x cannot be assigned to 18:43:42.869 - Script 'Players.Player.PlayerGui.TurretMover', Line 13 18:43:42.870 - Stack End" I went to the wiki and found out .x .y and .z are read only. So if I can't change the axis like that how else could I?

6 comments
It just keeps the part at -90, 0, -90..... https://gyazo.com/26fdaf6b4b07e797d77343b3e366175f
oops hang on, i thnk you're doing it backwards.
retry it now
It works, but one more thing if the whole model gets rotated the turret would still be on it's own axis. https://gyazo.com/c568eb4be6d6b325a08fa6a0205b7b3a
I can't do it. It's not that important anyway, ask a more advanced scripter :P
Ill try doing it myself :p