I tried setting the camera subject to a part at the back of the plane but I’m not sure what I’m doing wrong.
Here’s my code:
local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
function onSeated(isSeated, seat)
if isSeated then
print(seat.Name)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = seat.CamPart
end
end
Humanoid.Seated:Connect(onSeated)
I’m not getting errors in the output and the seat name is printing, also as you can see in the video Its changing the camera but the camera is not attaching to the cam part for some reason.
If there is a better way than CameraSubject let me know!
You can probably do this as well, I’m sure that there’s an easier solution to this though.
local RunService = game:GetService("RunService")
local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Camera = workspace.CurrentCamera
local func
function onSeated(isSeated, seat)
if isSeated then
print(seat.Name)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = seat.CamPart
func = RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(seat.CamPart.Position + Vector3.new(10, 5, 0))
end)
end
end
Humanoid.Seated:Connect(onSeated)
What I just did was import the RunService model and then begin an incredibly fast running loop using the .RenderStepped event and then inside that loop I would assign the CFrame of the Camera to 10 studs on the X-axis and 5 studs on the Y-axis away from the campart.
If you’d like to stop the loop in any scope, you can notice that I also assigned the loop to a variable. This way you can just check if the variable is nil or not, and then disconnect it like this and the loop will stop running:
if func then
func:Disconnect()
end
I am mentally ill as I do not know the difference between the X axis and the Z axis so choose between these two.
okay to add on this, you can go ahead and remove the loop, it’s very useless as you can add a weld constraint and it’ll do the same thing and it’ll preform better.
You change the coordinates according to however you want it to, as I said, the coordinates I put in may be incorrect. So just change up the axis values.
The issue isn’t the CameraSubject but rather your misunderstanding of how CameraType works. Changing the CameraType will change how the camera will function. So for example, you’re setting the CameraType to “Scriptable” taking a look at the documentation for CameraType you can see that the summary for Scriptable is “No default behavior. Used when developers need to script custom behavior.” Your issue is that you aren’t scripting any custom behaviour so the camera remains in a single position.
I’d recommend changing the CameraType to “Attach” as I think that will replicate the behaviour you’re trying to achieve. But play around with the different CameraTypes and see which one best fits your purpose.