How to detect thats a player is seated on a seat, with changer camera to CFrame?

Hi devs. My question is that i wana detect player and when they seat on a seat then the player change his camera to an part located within the Model named “DeskE” the seat is also included in that model.? Its like:

□□ | ■■ | □□

      __ Seat <

Meaning the poayer seat and triggered cam 1 so CFrame = Cam1 on cam1 i have included in that model DeskE a SurfaceGui and in that SurfaceGui i have buttons and by pressing these the CFrame will change by animation the Cam like click button left is Cam2, click button right is Came and so on??

1 Like

I’m having trouble understanding, but Humanoid.Seated will fire when a player sits in a seat.

Try

If seat.occupant == humanoid then

i would connect an event to detect seat changes then connect a camera event inside such as

local player=game.Players.LocalPlayer
local char=player.Character or player.CharacterAdded:Wait()
local playerHuman=char:WaitForChild("Humanoid")
local vehicleSeat=--get vehicle seat from model
local seatCam
local camera=game.Workspace.CurrentCamera
vehicleSeat.Changed:Connect(function(prop) --detect occupant change 
	if prop == "Occupant" then
		local humanoid = vehicleSeat.Occupant
		if humanoid==playerHuman then -- check its the local client/player
			seatCam=camera.Changed:Connect(function(prop)
				if prop == "CFrame" and camera.CameraType=="Scriptable" then
					--Do your camera stuff here
				end
			end)
		else
            if seatCam then --Disconnect camera changer when out of seat to prevent memory leaks
                seatCam:Disconnect()
    		    seatCam=nil
                camera.CameraType = Enum.CameraType.Custom
            end
		end
	end
end)

  1. Detect when the player sits
    Use the .GetPropertyChangedSignal("Occupant") on the Seat to check when someone sits down.

  2. Switch the camera to Scriptable
    When the seat gets occupied, set the player’s camera to Scriptable mode and move it to Cam1.

  3. Wire up your SurfaceGui buttons
    The buttons in the SurfaceGui can just tween the camera’s CFrame to the new positions (like Cam2, Cam3, etc.).

Here’s a rough script to get you started:

local seat = workspace.DeskE:FindFirstChild("Seat")
local cam1 = workspace.DeskE:FindFirstChild("Cam1")
local cam2 = workspace.DeskE:FindFirstChild("Cam2") -- etc.
local camera = workspace.CurrentCamera

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local humanoid = seat.Occupant
	if humanoid then
		local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
		if player then
			camera.CameraType = Enum.CameraType.Scriptable
			camera.CFrame = cam1.CFrame

			-- Optionally: store current camera state somewhere for use later
		end
	end
end)

Then for the SurfaceGui buttons (these should be LocalScripts, btw):

local button = script.Parent -- this is your button inside the SurfaceGui
local targetCam = workspace.DeskE:FindFirstChild("Cam2") -- or whatever cam you're moving to
local camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")

button.MouseButton1Click:Connect(function()
	local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
	local goal = {CFrame = targetCam.CFrame}
	TweenService:Create(camera, tweenInfo, goal):Play()
end)

And when the player gets up, you can just switch the camera back:

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if not seat.Occupant then
		camera.CameraType = Enum.CameraType.Custom
	end
end)