Getting Input Of Seated Player

I want to make a seat, similar to that of pilot seat from Build a Boat for Treasure, where the player can change its orientation with WASD keys, but I don’t have exact idea of how I would make that. Currently I have 2 main questions:

  1. How to “Lock” the seat’s rotation, so it stays the same until player changes it. - I have no idea at all on how to do that.
  2. How to control the seat. - I suppose, I could use Humanoid.Seated event to connect it to a function, and then in that function get the input of the player. But Im unsure if it is the best way.

However, I don’t have proper experience with seats, and I don’t even know if I should use vehicle seat or regular seat.

Any suggestions?

you could use AngularVelocity to lock the rotation and to rotate it, you can also use the steer and throttle properties of a vehicleSeat to control the rotation

1 Like

Are these properties only available for vehicle seat, or regular seat too?

only vehicle seat has throttle and steer, a regular seat does not

1 Like

Thank you, for some reason did not see at first, that you mentioned these properties are properties of Vehicle seat.

I tried to use the Occupant property of the seat to check if somebody is inside, and then use context action service to control it. But it didn’t quite work.

local contextActionService = game:GetService("ContextActionService")

local seat = script.Parent

local function Steer(input, inputState)
	if input == Enum.KeyCode.W and inputState == Enum.UserInputState.Begin then
		seat.AngularVelocity.AngularVelocity = Vector3.new(-1, 0, 0)
	elseif input == Enum.KeyCode.W and inputState == Enum.UserInputState.End then
		seat.AngularVelocity.AngularVelocity = Vector3.new(0, 0, 0)
	end
end

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant ~= nil then
		contextActionService:BindAction("Steering", Steer, false, Enum.KeyCode.W)
	elseif seat.Occupant == nil then
		contextActionService:UnbindAction("Steering")
	end
end)