How do i make a part point where the players mouse is facing when they are are sat in a seat?
Hello, I am currently working on a script for a tank where when the player is sat in the tank seat they can aim the turret on the front. I tried using a remote event to get the mouse position but then remembered that you cannot pass mouse properties. So, I placed a Local Script in StarterGui. It detects when the player sits but i cannot get the turret to then face where the mouse is pointing. Any help would be great!
Script in StarterGui:
1 | local mouse = game.Players.LocalPlayer:GetMouse() |
2 | local Part = game.Workspace.tank.shoot |
3 | game.Workspace.tank.Vehicle 1. VehicleSeat:GetPropertyChangedSignal( "Occupant" ):Connect( function () |
4 | if game.Workspace.tank.Vehicle 1. VehicleSeat.Occupant ~ = nil then |
6 | Part.CFrame = CFrame.new(Part.CFrame.p,mouse.Hit.p) |