Seat.Disabled not working locally for the first 20 seconds of the game

  1. What do you want to achieve? Keep it simple and clear!
    I am making an F-to-sit System, and I want to disable all seats (through scripting, because it is way easier than just highlighting all and setting Disabled to false) in order to make it so people don’t automatically sit if F-To-Sit if on for each seat.

  2. What is the issue? Include screenshots / videos if possible!
    When I set the Disabled property to false, it doesn’t register that seat as Disabled for 20 seconds after the Character Spawns.

Video (Uploaded on Streamable)

As shown in the above video, it was seating me when the Seat as disabled and I wasn’t pressing the F key. According to the code below, this did not work as functioned.

local SIT_DISTANCE = 7

local cas = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer

local seats = {}
local closestSeat = nil

for _,PART in pairs(workspace:GetDescendants()) do
	if PART:IsA("Seat") and not PART:FindFirstChild("Excluded") then
		table.insert(seats, PART)
		PART.Disabled = true
	end
end
workspace.DescendantAdded:Connect(function(D)
	if D:IsA("Seat") and not D:FindFirstChild("Excluded") then
		table.insert(seats, D)
		D.Disabled = true
	end
end)
workspace.DescendantRemoving:Connect(function(D)
	for i,v in pairs(seats) do
		if v == D then
			table.remove(seats,i)
			D.Disabled = false
		end
	end
end)

local marker = script:WaitForChild("SITTING")
marker.MaxDistance = SIT_DISTANCE

function SitRequest(name, state, input)
	if state == Enum.UserInputState.Begin then
		if closestSeat then
			if script.Parent.Humanoid.Sit == true then
			    return
			end
			wait()
			closestSeat:Sit(script.Parent.Humanoid)
		end
	end
end

if not game:GetService("UserInputService").TouchEnabled then
	cas:BindAction("SitRequest", SitRequest, false, Enum.KeyCode.F, Enum.KeyCode.ButtonX)
else
	marker.CLICKED.MouseButton1Down:Connect(function()
		SitRequest("SitRequest", Enum.UserInputState.Begin, Enum.KeyCode.F)
	end)
end

while true do
	local seat = nil
	local minDist = math.huge
	for _,s in pairs(seats) do
		local distance = player:DistanceFromCharacter(s.Position)
		if distance < SIT_DISTANCE and distance < minDist and not s.Occupant then
			if s:FindFirstChild("Booked") then
				if s.Booked.UserId.Value == player.UserId then
					seat = s
					minDist = distance
				end
			else
				seat = s
				minDist = distance
			end
		end
	end
	if script.Parent.Humanoid.Sit == true then
		closestSeat = nil
	else
		closestSeat = seat
	end
	marker.Adornee = closestSeat
	marker.Enabled = (closestSeat ~= nil)
	if game:GetService("UserInputService").TouchEnabled then
		marker.CLICKED.ImageTransparency = 0
		marker.BUTTON.Text = ""
	elseif game:GetService("UserInputService").GamepadEnabled then
		marker.CLICKED.ImageTransparency = 1
		marker.BUTTON.Text = "X"
	elseif game:GetService("UserInputService").KeyboardEnabled then
		marker.CLICKED.ImageTransparency = 1
		marker.BUTTON.Text = "F"
	end
	wait(0.1)
end

(The variable labelled “Marker” is a Billboard GUI, as shown in the video)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried Disabling each seat as it was set to the “closestSeat” variable, but alas that did not work as planned.

This could be classified as an Engine Bug, I really have no clue, but it is an issue nonetheless. I want to ensure that before I say this is a ROBLOX Client issue that this is not an issue with my scripting.

As that code is a LocalScript, then you should not (and cannot always) do client-sided modification of the Workspace, as the server’s Workspace is “the only truth”.

So move your disable/enable of the seats into a server-sided Script.

You would still need to enumerate the seats in the client-sided LocalScript, but since it is the server that most likely has network-ownership of the seat-blocks at game start, then it is futile to have a LocalScript attempt to control the disable/enable property.

Still there are problems when a player request to sit in a seat. As the seat does not instantly gets (automatic) network-ownership transferred from server to “the nearest client”, then that is most likely what you observe as your problem, when it “takes 20 seconds.” - Take a look at this ‘Network Ownership’ article.

So I do not think it is an ‘Engine Bug’, but more likely “something technical you do not yet know of, when using Roblox’s framework, and therefore need to study, read and experiment with it much more.

Also the SitRequest, which in your code is currently in a (client-sided) LocalScript, should be moved into a (server-sided) Script, and then be using RemoteEvent, so the client will send a “request” (via the RemoteEvent to the server) for being seated into the seat. - The (server-sided) Script code should then validate that the incoming “request” from the player can be performed correctly (so exploiting can be avoided), and the (server-sided) Script then performs the actual action of “sitting the player into the requested seat.”