How would I get it so when a player is in a Vehicle seat, the players camera will focus on a part called Focus in the Vehicle instead of on the Vehicle seat? (As the vehicle is remote controlled in this case.)
This would require 2 scripts, a LocalScript and just a plain script.
Put the following code into a LocalScript and insert the script into game.Lighting:
local vehicle = game.Workspace.Vehicle local camera = game.Workspace.CurrentCamera if camera.CameraSubject == vehicle.Focus then camera.CameraSubject = game.Players.LocalPlayer else camera.CameraSubject = vehicle.Focus end
The following code goes in a Script
local seat = game.Workspace.Seat local vehicle = game.Workspace.Vehicle seat.ChildAdded:connect(function(child) -- a weld is inserted into the seat when a player sits on it if child:IsA("Weld") then -- check to see if the child that was inserted is a weld local character = child.Part1.Parent --local player = game.Players:GetPlayerFromCharacter(character) local cameraScript = game.Lighting.LocalScript:Clone() cameraScript.Parent = character -- insert the localscript into the character so it runs locally seat.ChildRemoved:wait() -- weld is removed when player stands up cameraScript.Disabled = true -- run script again cameraScript.Disabled = false cameraScript:Destroy() end end)
Tested and it works. This code will set a players CameraSubject to a part named "Focus" in Workspace.Vehicle when they sit on the seat (Workspace.Seat) and when they stand up the CameraSubject will be reset (to the player's humanoid.)