All characters has a HRP(HumanoidRootpart) set as PrimaryPart, which you can use :SetPrimaryPartCFrame(seat.CFrame * CFrame.new(0,4,0))
.
Attempting Solution – which is already too much to ask for – untested
local vehicle -- the vehicle model
local hitToSeat -- part of the vehicle
local seatTable = {} do
for i, v in next, vehicle:GetDescendants() do
if v:IsA("Seat") or v:IsA("VehicleSeat") then
table.insert(seatTable, v:IsA("VehicleSeat") and 1 or #seatTable, v)
v:GetPropertyChangedSignal("Occupant"):Connect(function()
if not v.Occupant then
table.insert(seatTable, v:IsA("VehicleSeat") and 1 or #seatTable, v)
end
end)
end
end
end
hitToSeat.Touched:Connect(function(touched)
if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
if #seatTable > 0 then
touched.Parent:SetPrimaryPartCFrame(seatTable[1].CFrame * CFrame.new(0,4,0))
table.remove(seatTable, 1)
end
end
end)
Report any odd errors, this was written raw and not in Studio.
Optional
Use the Seat:Sit(touched.Parent.Humanoid)
instead, which then does not require any teleportation immediately.
The script would look like this:
local vehicle -- the vehicle model
local hitToSeat -- part of the vehicle
local seatTable = {} do
for i, v in next, vehicle:GetDescendants() do
if v:IsA("Seat") or v:IsA("VehicleSeat") then
table.insert(seatTable, v:IsA("VehicleSeat") and 1 or #seatTable, v)
v:GetPropertyChangedSignal("Occupant"):Connect(function()
if not v.Occupant then
table.insert(seatTable, v:IsA("VehicleSeat") and 1 or #seatTable, v)
end
end)
end
end
end
hitToSeat.Touched:Connect(function(touched)
if touched.Parent:IsA("Model") and touched.Parent:FindFirstChild("Humanoid") then
if #seatTable > 0 then
seatTable[1]:Sit(touched.Parent.Humanoid)
table.remove(seatTable, 1)
end
end
end)
And finally, if it’s not driven by a player, ignore VehicleSeat
and replace table.insert(seatTable, v:IsA("VehicleSeat") and 1 or #seatTable, v)
with table.insert(seatTable, v)
.
Automatic driving or enabling it will require that the #seatTable <= 0
is true.