Vehicle Seat Prompts

I’m working on a prompt system for my modified a-chassis. I want it so when a player enters a seat in the car it disables the prompt in the seat they are sitting in, and then I have a LocalScript that is supposed to disable all the seat prompts on their client side so they can’t see the other prompts in the car.

The ServerScript is working but the LocalScript doesn’t disable the prompts

ServerScript:

local passengerSeats = script.Parent
local driverSeat = script.Parent.Parent.Parent:FindFirstChild("DriveSeat")
local PromptHide = Instance.new("RemoteEvent")
PromptHide.Name = "SeatsPrompt"
PromptHide.Parent = game:GetService("ReplicatedStorage").CarSystem.Events

-- Function to disable the prompt inside the seat when a player sits in it
local function DisableSeatPrompt(seat)
	local prompt = seat:FindFirstChild("ProximityPrompt")
	if prompt then
		prompt.Enabled = false
	end
end

-- Passenger Seats
for _, seat in ipairs(passengerSeats:GetChildren()) do
	if seat:IsA("Seat") then
		local prompt = seat:FindFirstChild("ProximityPrompt")
		if prompt then
			prompt.Triggered:Connect(function(player)
				if seat.Occupant == nil then
					seat:Sit(player.Character.Humanoid)
					prompt.Enabled = false
					PromptHide:FireClient(player)
				end
			end)
		end
	end
end

-- Driver Seat
local driverPrompt = driverSeat:FindFirstChild("ProximityPrompt")
if driverPrompt then
	driverPrompt.Triggered:Connect(function(player)
		if driverSeat.Occupant == nil then
			driverSeat:Sit(player.Character.Humanoid)
			driverPrompt.Enabled = false
			PromptHide:FireClient(player)
		end
	end)
end

LocalScript:

local PromptHide = game:GetService("ReplicatedStorage").CarSystem.Events.SeatsPrompt

-- Listen to the HidePrompts event from the server and disable all seat prompts on the client
PromptHide.OnClientEvent:Connect(function(player)
	for _, seat in ipairs(passengerSeats:GetChildren()) do
		if seat:IsA("Seat") then
			local prompt = seat:FindFirstChild("ProximityPrompt")
			if prompt then
				prompt.Enabled = false
			end
		end
	end
end)

image

Why do you need to disable them on the client? The reason it doesn’t work is because its a LocalScript, localscripts don’t run in workspace, just disable the prompts on the server…

Try moving the local script into starter player scripts if you want the prompts to only disable for the person that uses the car seat.

Modified your code a little, local scripts don’t run in the workspace unless they’re parented to a player’s character. For now, I made the script parent the local script to the player’s character when the function is executed.

If you want your system to have local scripts, you could probably make a folder of all the client scripts and parent them to the seat.Occupant.Parent (character) in order for them to run and when the seat has no occupant, loop through the character and delete the local scripts you added.

Disable Function

local function DisableSeatPrompt(seat)
	local prompt = seat:FindFirstChild("ProximityPrompt")
	if prompt then
		prompt.Enabled = false
        seat.Parent.ClientPrompts.Parent = player.Character
        task.wait(.1)
        PromptHide:FireClient(player, passengerSeats)
	end
end

Client

PromptHide.OnClientEvent:Connect(function(player, passangerSeats)
	for _, seat in ipairs(passengerSeats:GetChildren()) do
		if seat:IsA("Seat") then
			local prompt = seat:FindFirstChild("ProximityPrompt")
			if prompt then
				prompt.Enabled = false
			end
		end
	end
end)