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