I was making a camera where you can view your train from different angles. It worked, however you could only see the first train that was spawned in the game. I don't know why and I can't fix it.

local CameraViewButton = script.Parent
local Camera = game.Workspace.CurrentCamera
local CameraView = 1
local TrainSeat = game.Workspace.Model.C153.C153.MachinistSeat
local Seat = game.Players.LocalPlayer.Character.Humanoid.SeatPart

function ChangeCamera(View)
	if View == 1 then
		game:GetService("RunService"):UnbindFromRenderStep("UpdateCamera")
		Camera.CameraType = "Custom"
		Camera.CameraSubject = TrainSeat
	elseif View == 2 then
		Camera.CameraType = "Watch"
		Camera.CameraSubject = TrainSeat.Parent
	elseif View == 3 then
		Camera.CameraType = "Scriptable"
		game:GetService("RunService"):BindToRenderStep("UpdateCamera", Enum.RenderPriority.Camera.Value - 1, function()
			Camera.CoordinateFrame = CFrame.new(Seat.Parent.Poles.Position) * CFrame.Angles(math.rad(0), math.rad(Seat.Parent.Poles.Orientation.Y + 30), math.rad(0))
		end)
	end
end

function ChangeCameraView()
	CameraView = CameraView + 1
	if CameraView == 4 then
		CameraView = 1
	end
	ChangeCamera(CameraView)
end

CameraViewButton.MouseButton1Click:connect(ChangeCameraView)
	

2 comments

0

Yeah I know that, but it's when you press the BUTTON, you can "only see the first train that was spawned in the game."