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.
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.