Delay between entering seats?

I have a problem where, if numerous seats are together, upon leaving one seat and touching with another nearby, the player will immediately hop into another seat if they’re close to one another.

I would need some advice or code samples to write a system that works by creating a boolean which will initiate when leaving a seat and detect if a seat is touched. This will end the function if the boolean is true. Simply put, I’d need a “debounce” system that will wait() to deter rapidly switching seats. And if possible, I will also disable the right and left arm from enabling the seat within this function as well.

Any help will be appreciated, thanks!

Here’s a cool trick you can do: disable the Enum.HumanoidStateType.Seated state.

LocalScript inside StarterCharacterScripts:

--!strict

local SEAT_COOLDOWN: number = 1

local Character: Model = script.Parent :: Model
local Humanoid: Humanoid = Character:WaitForChild("Humanoid") :: Humanoid

Humanoid.StateChanged:Connect(function(oldState: Enum.HumanoidStateType): ()
	if oldState == Enum.HumanoidStateType.Seated then
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
		task.wait(SEAT_COOLDOWN)
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
	end
end)
1 Like