I made this script (in ServerScriptService) that is supposed to disable all the prompts when sitting on a seat. If someone is sitting on a seat, it will hide the Proximity Prompt for other Players. (spoiler it dosent)
local cols = game:GetService("CollectionService")
local seats = cols:GetTagged("Seat")
-- Initialize prompts for each seat
for _, seat in ipairs(seats) do
-- Create a Proximity Prompt for the seat
local prompt = Instance.new("ProximityPrompt")
prompt.ActionText = "Sit"
prompt.ObjectText = seat.Name
prompt.RequiresLineOfSight = false
prompt.Parent = seat
prompt.Enabled = false -- Initially disabled
-- Function to update the visibility based on whether the seat is occupied
local function updatePromptVisibility()
-- If there is an occupant, disable the prompt; otherwise enable it
prompt.Enabled = not seat.Occupant
end
-- Update prompt visibility on initialization
updatePromptVisibility()
-- Event when a player triggers the prompt
prompt.Triggered:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Sit the player in the seat
seat:Sit(humanoid)
-- Update visibility immediately after sitting down
prompt.Enabled = false
-- Listen for the occupant changing to update visibility
local occupantChangedConnection
occupantChangedConnection = seat:GetPropertyChangedSignal("Occupant"):Connect(function()
updatePromptVisibility()
-- Clean up the connection if the occupant changes to nil
if not seat.Occupant then
occupantChangedConnection:Disconnect()
end
end)
-- Clean up when the humanoid dies
humanoid.Died:Connect(function()
-- Disconnect the occupant changed connection
occupantChangedConnection:Disconnect()
-- Call the update prompt visibility function
updatePromptVisibility()
end)
end)
-- Also connect to the property changed signal to ensure prompt visibility
seat:GetPropertyChangedSignal("Occupant"):Connect(updatePromptVisibility)
end
-- Function to refresh prompts for all seats; especially useful for complex seat changes
local function refreshAllPrompts()
for _, seat in ipairs(seats) do
local prompt = seat:FindFirstChildOfClass("ProximityPrompt")
if prompt then
prompt.Enabled = not seat.Occupant
end
end
end
-- Connect to the general seat property changes, ensuring prompts refresh
for _, seat in ipairs(seats) do
seat:GetPropertyChangedSignal("Occupant"):Connect(refreshAllPrompts)
end
Seat Properties:

My problem is that when a player sits down and then exits the seat, they can still see the Proximity Prompt for seats that are occupied by other players, even though the script is supposed to hide it.