--Get in a seat

local function enterStart()
	--Tell server we're trying to get in
	GetInStart:FireServer(AdornedSeat)

	--Wait until player lets go of button (causing them to get in) or seat out of range (nothing happens)
	while EnterKeyDown and AdornedSeat do
		wait()
	end

	if AdornedSeat then
		--Tell server we are getting in seat
		Remotes.GetInSeat:FireServer(AdornedSeat)
		local n = 0
		repeat
			wait()
			n = n + 1
		until AdornedSeat == nil or n>20
		EnterImageButton.Visible = true
		
		local hum = getLocalHumanoid()
		if hum then
			if hum.Sit then
				-- load animations only when player is in the vehicle
				local hum = getLocalHumanoid()
				if hum ~= currentHumanoid then -- load only when we have a new humanoid
					currentHumanoid = hum
					local anims = animationFolder:GetChildren()
					for i = 1, #anims do
						AnimationTracks[anims[i].Name] = hum:LoadAnimation(anims[i])
					end
				end
				
				-- play seated animation
				local seat = hum.SeatPart
				local prefix = (seat.ClassName == "VehicleSeat" and "Driver" or "Passenger")
				local preferredAnimation = AnimationTracks[prefix.."_Seated"]
				if preferredAnimation then
					preferredAnimation.Priority = Enum.AnimationPriority.Action
					preferredAnimation:Play()
				end
			end
		end
	end
end
