Search for vehicles currently on board

Hi!
I am currently working on a vehicle script and am looking for a way to search for the vehicleseat I am sitting on.

For example,

local a = game.Workspace.vehicle

The above script may cause an error when there are multiple “vehicle” models.
(My vehicle will have multiple models of the same model using a spawner.)

I’m trying to control a vehicle from a GUI script cloned into the player, so please advise on how to find the model containing the Vehicleseat the player is sitting on!

You could use magnitude to see how close the player is to the seat or you can loop through all of the seats and check if the occupant == to your character i hope that kinda helps

Thanks for the quick support!
I found SeatPart in the middle of trying to figure out how to loop all the seats.
I will try based on your tips.

Self resolved!

function getSeat()
	local players = game:GetService("Players")
	local player = players.LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	
	local Seat = humanoid.SeatPart.Parent
end

getSeat()

It works with a local script cloned into the player.

local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")

local function OnSeatPartChanged()
	print(Humanoid.SeatPart.Name)
end

Humanoid:GetPropertyChangedSignal("SeatPart"):Connect(OnSeatPartChanged)
1 Like