Player can't sit in seat after its been disabled

Hello! So basically, I have a script which I’m part referencing from a youtube video but adapting for my own needs and what it does it locks/unlocks a seat. The current way I’m doing this is by setting disbled to true or false however, when I am sat in the seat and then disable it, my character can then no longer sit in any seat.

Any help is appreciated :slight_smile:

-- My script (Local Script)
local RS = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Local = Players.LocalPlayer
local Char = Players.LocalPlayer.Character
local Input = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	local MaxDistance = 20
	for i, v in pairs(game.Workspace.Vehicles:GetChildren()) do
		if (v.VehicleSeat.Position - Char.HumanoidRootPart.Position).magnitude < MaxDistance and v.VehicleSeat.Occupant == nil then
			LocalNearSeat = v.VehicleSeat
			if v.VehicleSeat.Disabled == false then
				Local.PlayerGui.LToLock.Adornee = v.VehicleSeat
				Local.PlayerGui.LToUnlock.Adornee = nil
				Local.PlayerGui.Locked.Adornee = nil
			elseif v.VehicleSeat.Disabled == true then
				Local.PlayerGui.LToUnlock.Adornee = v.VehicleSeat
				Local.PlayerGui.LToLock.Adornee = nil
				Local.PlayerGui.Locked.Adornee = nil
			end
		end
	end
end)


Input.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.L then
		if LocalNearSeat.Disabled == false then
			LocalNearSeat.Disabled = true
		elseif LocalNearSeat.Disabled == true then
			LocalNearSeat.Disabled = false
		end
	end
end)


1 Like

i guess your problem is when the player seats on the seat and when you disable that seat the SIT boolean in the player’s humanoid won’t set to False and the game thinks the player is still sitting and it won’t let the player to seat on any other things

1 Like

You can do this by calling Char:Jump() right before you lock the seat. In that case, the sit boolean as mentioned above will be reseted to false and you can sit on other seats again.

1 Like

Before lock your car you should use Humanoid:Jump() since sit boolean will be reseted to false and you should reset your roblox character then. Agreed with @Boele009

2 Likes