Disable all seats from a vehicle for the player

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? So, each seat in the vehicle I’m making, including the driver one, has a ProximityPrompt inside which I want to disable only for the player if they enter a seat (any seat, doesn’t matter if it’s for the driver) and I don’t know what I should do, I tried using RemoteEvents but LocalScripts don’t run in the Workspace

  2. What is the issue? I tried using RemoteEvents, but I can’t run them locally because of being in the Workspace

  3. What solutions have you tried so far? I haven’t found anything that helps me with that in the DevForum

1 Like

Why not use Collectionservice to tag the player that is on the seat on the server then use collection service on the client to validate whether the player on the seat matches the local player then disable all the proximity prompts.

1 Like

And for remoteEvents why not store the local scripts in StarterCharacterScripts or StarterGui then use FireClient() on the server

1 Like

Because the vehicles are spawned by the player so there isn’t only one script for only one vehicle, so I think that wouldn’t work properly

I will try that, thanks in advance. I will come back if I need help in another thing :wink:

ok goodluck i will respond if you need help

Hi again, could you provide me with some example of how I could use the CollectionService for that? I really haven’t worked with it before, thanks in advance :wink:

It should be structured similar to this but if you have problems accessing the prompts then change the object your looking for to the vehicle so a model then just look through the model for the parts.

local CollectionService = game:GetService("CollectionService")

local tag = "SeatTag" --write your own tag name


-- Store the connections so they can be disconnected when the tag is being removed
local connections = {}

local function onInstanceAdded(object)
	-- Confirm that the object with this tag is a Vehicleseat.
	if object:IsA("VehicleSeat") then --this can be your vehicle model either
        connections[object]=true
		-- write code to disable prompts
	end
end

local function onInstanceRemoved(object)
	if connections[object] then
		connections[object] = nil
                --write code to enable prompts for the player
	end
end

-- Detect for this tag being applied to objects
CollectionService:GetInstanceAddedSignal(tag):Connect(onInstanceAdded)
CollectionService:GetInstanceRemovedSignal(tag):Connect(onInstanceRemoved)

-- Lisent for any objects that already have the tag 
for _, object in pairs(CollectionService:GetTagged(tag)) do
	onInstanceAdded(object)
end
1 Like

Thanks for the code! But I figured it out yesterday, thank you again for helping me :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.