I recently have been trying to make an ELS system for my cars. I need to change a “Bool-Value” by pressing a key only for the driver in the driver’s seat. Does anyone know how to do so?
Seats do have a property called Occupant.
It returns the character’s humanoid which is seating on it, so for this you can just check that if the player is the same as the occupant one then change the bool value, also, don’t forget to use a RemoteEvent to change it.
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
local Remote = ReplicatedStorage.Remote -- Remote to change the bool value
local Seat = workspace.Car.DriveSeat
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
local SeatClient = Players:GetPlayerFromCharacter(Seat.Occupant.Parent)
if input.KeyCode == Enum.KeyCode.E and SeatClient.UserId == Client.UserId then
Remote:FireServer()
end
end)