Problem with hide prompts locally script

Hello, sometime ago some folks of Devforum helped me with making a script to hide proximity prompts only for the player sitting on the vehicle, which shouldnt be hard, but yea its hard and you need 3 degrees to do that lol

It is partially working but the bug is, you are sitting on the driver seat for example, then a passanger enters on your side, then he leaves the car, the proximity prompt will appear on that seat while you driving, making it hard to leave the vehicle without changing seats and its visually bad.

heres the server script

local storage = game:WaitForChild("ReplicatedStorage")
local players = game:GetService("Players")
local event = storage:WaitForChild("ProximityPrompts")

local formerPlayer = {}

for _, seat in pairs(workspace.Vehicles:GetDescendants()) do
	if seat:IsA("Seat") or seat:IsA("VehicleSeat") then
		seat:GetPropertyChangedSignal("Occupant"):Connect(function()
			local player = seat.Occupant and players:GetPlayerFromCharacter(seat.Occupant.Parent)
			if player then
				event:FireClient(player, false)
				formerPlayer[seat] = player
			else
				event:FireClient(formerPlayer[seat], true)
				formerPlayer[seat] = nil
			end
		end)
	end
end

local script

local storage = game:WaitForChild("ReplicatedStorage")
local event = storage:WaitForChild("ProximityPrompts")

local function ToggleOnOff(state)
	for _, proximityPrompt in pairs(workspace.Vehicles:GetDescendants()) do
		if proximityPrompt:IsA("ProximityPrompt") then
			proximityPrompt.Enabled = state
		end
	end
end

event.OnClientEvent:Connect(ToggleOnOff)

any help is very appreciated! since this is one of the core parts of my game

1 Like

the problem is that you are enabling and disabling it on the server. Meaning that whenever someone gets in the vehicle, it will hide for them and other players, but when someone gets in and leaves, it will show up again for the player that is already in the vehicle seat. So, instead of firing an event, do it on the client.

so if i invert and put the localscript on the serverscript and vice versa it should work?

yes, it should work on the client instead of the server.

is there something to do with the server script?

oh, wait, I just realized I read it wrong… sorry lol. You were already doing it on the client and not the server. There shouldn’t exactly be any problems with the script. Since it’s on the client there shouldn’t be anyone being affected. Do the seats all have the same name? I’m not exactly an expert on this type of thing.

sorry for the late response, but all the seats have different names example seatfr seatrr