✓ Accepted answer
This is what i would do:
while true do
local part = Your part
local Occupants = {}
part.Touched:Connect(function(hit)
for i,v in pairs(hit.Parent.model:GetChildren()) do
if v:IsA("VehicleSeat") then
if v.Occupant ~= nil then
table.insert(Occupants,v.Occupant.Parent)
end
end
end
print("There are "..#Occupants.." on this vehicle")
end
if #Occupants == 5 then
for i = 0,100,0.01 do
script.Parent:TranslateBy(Vector3.new(i,0,0))
wait(0.05)
wait()
end
end
end
end)
Im assuming that you mean that 5 players have to be seated in the model. I don't really know what you mean with "inside the vehicle."
I hope this helps, if this doesn't help just send a message.
2 comments
If you don't know what Seat.Occupant is: https://developer.roblox.com/en-us/api-reference/property/Seat/Occupant
I only have 1 error saying Touched isn't a valid member of Model.