Seat.Disabled Not Working

I’m trying to make a seat that you click to sit, it all works except the part where the seat is disabled until someone clicks it to avoid players touching it to sit but when I test the game seat.Disabled doesn’t change.

I have tried changing the property in the script and in the property’s window and still, it hasn’t worked.

When I was trying to find a solution I saw this was a bug a while ago but they said it was fixed.

Old post: Client ignores server changes to seat Disabled property

The bug report you linked has been solved aleady. I cannot reproduce the bug.

Could you share your code so we can take a look?

local seat = script.Parent.Seat
local block = script.Parent.block
local inuse = false

seat.Disabled = true

block.ClickDetector.MouseClick:Connect(function(plr)
	if plr.Character.Humanoid.Sit == false then
		if inuse == false then
			inuse = true
			seat.Disabled = false
			plr.Character.Humanoid.JumpPower = 0
			plr.Character.HumanoidRootPart.CFrame = seat.CFrame
			block.ClickDetector.MaxActivationDistance = 0
		
			game.ReplicatedStorage.SeatLock.LeaveSeat:FireClient(plr)
			
			game.Players.PlayerRemoving:Connect(function(plrLeft)
				if plrLeft == plr then
					wait(3)
					block.ClickDetector.MaxActivationDistance = 10
					inuse = false
				end
			end)
		
			game.ReplicatedStorage.SeatLock.LeaveSeat.OnServerEvent:Connect(function()
				seat.Disabled = false
				plr.Character.Humanoid.Sit = false
				plr.Character.Humanoid.JumpPower = 50
				wait(3)
				block.ClickDetector.MaxActivationDistance = 10
				inuse = false
			end)
		end
	end
end)

I’d also like to note that exploiters can force their character to sit on disabled seats by either enabling the seat on their client or using the seat API Seat:Sit(Humanoid) so you will have to implement server checks to avoid making this vulnerability game breaking. This is not related to the bug report.

As for your code, I improved it a bit:

local seat = script.Parent.Seat
local block = script.Parent.block

--make the seat disabled by default in studio

block.ClickDetector.MouseClick:Connect(function(plr)
	local Character = plr.Character
	if Character and Character.Humanoid.Sit == false and seat.Occupant == nil then
		Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
		seat:Sit(Character.Humanoid)
		block.ClickDetector.MaxActivationDistance = 0
		
		game.ReplicatedStorage.SeatLock.LeaveSeat:FireClient(plr)
		
		game.Players.PlayerRemoving:Connect(function(plrLeft)
			if plrLeft == plr then
				wait(3)
				block.ClickDetector.MaxActivationDistance = 10
			end
		end)
		
		game.ReplicatedStorage.SeatLock.LeaveSeat.OnServerEvent:Connect(function()
			plr.Character.Humanoid.Sit = false
			Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
			wait(3)
			block.ClickDetector.MaxActivationDistance = 10
		end)
	end
end)

I changed jump power to the humanoid state and removed some variables because they seem redundant since you can check with the available properties from the objects you’re using such as Seat.Occupant. I’m not sure what your exact use case is so if I missed something, just tell me.

3 Likes

Thank you so much, this is great!

I’ve made a request on fixing this flawed behavior.