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:
local mouse = game.Players.LocalPlayer:GetMouse() local Part = game.Workspace.tank.shoot game.Workspace.tank.Vehicle1.VehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function() if game.Workspace.tank.Vehicle1.VehicleSeat.Occupant ~= nil then print("player sat") Part.CFrame = CFrame.new(Part.CFrame.p,mouse.Hit.p) end end)
mouse.Move:Connect(function() Part.CFrame = CFrame.new(Part.CFrame.Position,mouse.Hit.Position) end)