I made this cool(ish) turret that points where your mouse is. It keeps randomly pointing towards the ground even though it's on a HingeConstraint.
--Script (Turret)
local Turret = script.Parent
local Body = Turret.Body
Body.Seat.ChildAdded:Connect(function(Child)
if Child:IsA("Weld") then
game.ReplicatedStorage.TurretSit:FireClient(game.Players:GetPlayerFromCharacter(Child.Part1.Parent))
end
end)
game.ReplicatedStorage.MoveTurret.OnServerEvent:Connect(function(Player, Mouse)
Body:PivotTo(CFrame.lookAt(Body.Seat.Position, Vector3.new(Mouse.X, 0, Mouse.Z), Vector3.new(0, 0, 1)))
end)
--LocalScript (StarterCharacterScripts)
local Hum = script.Parent.Humanoid
game.ReplicatedStorage.TurretSit.OnClientEvent:Connect(function()
while Hum.Sit do
local Mouse = game.Players.LocalPlayer:GetMouse()
game.ReplicatedStorage.MoveTurret:FireServer(Mouse.Hit)
task.wait(0.1)
end
end)