ProximityPrompts

Hello, I would like to hide 4 different proximity prompts when the player enters a seat on the vehicle.

Basically, when the driver enters the driver seat, all the prompts are invisible so you cannot see them until you get back out.

As well as this, I would like to do the same for when a passenger enters the passenger seat.

1 Like

To do this, you will need to use a LocalScript to avoid disabling the ProximityPrompts for everyone. Make sure the LocalScript is not descendant of Workspace, otherwise the script will not run (unless if it’s parented to the character).

Here is an example of what your LocalScript should look like:

-- first locate all your ProximityPrompts
local Prompt1 
local Prompt2
local Prompt3
local Prompt4

-- now to disable them all once the player sits on the driver's seat
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hum = character:WaitForChild("Humanoid")

local DriverSeat -- locate your driver's seat part here

hum.Seated:Connect(function(active, currentSeat)
	if active and currentSeat == DriverSeat then -- if active is 'true' and 'currentSeat' is the Driver's Seat
		Prompt1.Enabled = false
		Prompt2.Enabled = false
		Prompt3.Enabled = false
		Prompt4.Enabled = false
	else -- if player got out of the seat
		Prompt1.Enabled = true
		Prompt2.Enabled = true
		Prompt3.Enabled = true
		Prompt4.Enabled = true
	end
end)

If all 4 ProximityPrompts are in 1 specific Folder/Model/Part (of a main part), then it’s best to use a for loop.

So how would I make it so that this script can be placed directly in the Seat it’s self and works the same way?

I need the script so that when you get in the seats of the vehicle it hides the prompts within the vehicle its self.

This will not work because as I have said, LocalScripts as a descendant of Workspace will not run (meaning if the LocalScript is parented to Workspace or parented to a part that is parented to Workspace etc etc will not run).

If you want this to apply to passengers as well, just create more variables of those seats, and mention them in the if statement before disabling the ProximityPrompts.

Edit:
Could you please show your workspace hierarchy that includes the driver’s seat and ProximityPrompt?

image

You could actually do this another way. This time, you are going to use RemoteEvents.
First, create a RemoteEvent under ReplicatedStorage named DisableProximityPrompt (or whatever else you want it to be). Then have a ServerScript under each (driver’s) seat and run the following code below (if you have a Main Script for each vehicle, you can also run the code in that instead):

local Players = game:GetService("Players")
local RP = game:GetService("ReplicatedStorage")
local Event = RP:WaitForChild("DisableProximityPrompt")

local seat -- if you are going to have each script under the seat, just do 'script.Parent'

-- locate all your prompts for specific vehicle
local Prompt1 
local Prompt2
local Prompt3
local Prompt4

local curPlayer = nil

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local hum = seat.Occupant

	if hum and hum:IsA("Humanoid") then
		local char = hum.Parent
		local player = Players:GetPlayerFromCharacter(char)
		
		if player then
			curPlayer = player
			Event:FireClient(player, true, Prompt1, Prompt2, Prompt3, Prompt4)
		end
	end
	
	if curPlayer then
		Event:FireClient(curPlayer, false, Prompt1, Prompt2, Prompt3, Prompt4)
		curPlayer = nil
	end
end)

Now have a LocalScript under StarterPlayerScripts, and use the following code below:

local Event = game.ReplicatedStorage:WaitForChild("DisableProximityPrompt")

Event.OnClientEvent:Connect(function(inSeat, Prompt1, Prompt2, Prompt3, Prompt4)
	if inSeat then -- if currently seated
		Prompt1.Enabled = false
		Prompt2.Enabled = false
		Prompt3.Enabled = false
		Prompt4.Enabled = false
	else
		Prompt1.Enabled = true
		Prompt2.Enabled = true
		Prompt3.Enabled = true
		Prompt4.Enabled = true
	end
end)
1 Like