You can write your topic however you want, but you need to answer these questions:
-
I am working on a tank turret system that follows the mouse.
-
Because I am using a body gyro on render stepped the body gyro keeps trying to face the mouse even if it is already perfect on the mouse.
-
I have tried 3 solutions mainly. The first is moving to a WASD turret which worked fine but is undesirable as people didn’t seem to like WASD. The second is using mouse.Move which worked to an extent but would make the turret rotate weirdly as it would only go to the previous position of the mouse. Lastly, I tried getting the distance between a starting and moved the position of the mouse every render stepped which did not work at all.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
RunService.RenderStepped:Connect(function()
if camera.CFrame.Position ~= Mouse.Hit.Position then
Mouse.TargetFilter = vehicle
Tool.Important.Events.Turn:FireServer(Mouse.Hit.Position)
end
end)```
Client
```lua
local function Turn(player, ToP, camera)
vehicle.Body.Turret.TurretGyro.BodyGyro.CFrame = CFrame.lookAt(vehicle.Body.Turret.TurretGyro.Position, ToP)
vehicle.Body.Turret.Turret.TargetAngle = vehicle.Body.Turret.TurretGyro.GyroHinge.CurrentAngle
vehicle.GunGyro.BodyGyro.CFrame = CFrame.lookAt(vehicle.GunGyro.Position, ToP)
vehicle.Body.gunhing.HingeConstraint.TargetAngle = vehicle.GunGyro.HingeConstraint.CurrentAngle
vehicle.Body.Sight.HingeConstraint.TargetAngle = vehicle.GunGyro.HingeConstraint.CurrentAngle
end
Tool.Important.Events.Turn.OnServerEvent:Connect(Turn)```
Server